List

Python

Python - Sort List of Tuples

Python sorts lists of tuples lexicographically by default. The comparison starts with the first element of each tuple, then moves to subsequent elements if the first ones are equal.

Read more →
Python

Python - Reverse a List

• Python offers five distinct methods to reverse lists: slicing ([::-1]), reverse(), reversed(), list() with reversed(), loops, and list comprehensions—each with specific performance and…

Read more →
Python

Python - List to String Conversion

The join() method is the most efficient approach for converting a list of strings into a single string. It concatenates list elements using a specified delimiter and runs in O(n) time complexity.

Read more →
Python

Python - Get Length of List

The len() function returns the number of items in a list in constant time. Python stores the list size as part of the list object’s metadata, making this operation extremely efficient regardless of…

Read more →
Python

Python - Find Min/Max in List

• Python offers multiple approaches to find min/max values: built-in min()/max() functions for simple cases, manual iteration for custom logic, and heapq for performance-critical scenarios with…

Read more →
Python

Python - Filter List with Examples

List comprehensions provide the most readable and Pythonic way to filter lists. The syntax places the filtering condition at the end of the comprehension, creating a new list containing only elements…

Read more →
Python

PySpark - Create DataFrame from List

PySpark DataFrames are the fundamental data structure for distributed data processing, but you don’t always need massive datasets to leverage their power. Creating DataFrames from Python lists is a…

Read more →
Python

NumPy - Convert List to Array

The fundamental method for converting a Python list to a NumPy array uses np.array(). This function accepts any sequence-like object and returns an ndarray with an automatically inferred data type.

Read more →
Linux

Linux lsof: List Open Files

The lsof command (list open files) is an indispensable diagnostic tool for anyone managing Linux systems. At its core, lsof does exactly what its name suggests: it lists all files currently open on…

Read more →