Sort

R

R dplyr - arrange() - Sort Data Frame

The arrange() function from dplyr provides an intuitive interface for sorting data frames. Unlike base R’s order(), it returns the entire data frame in sorted order rather than just indices.

Read more →
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

PySpark - Sort in Descending Order

Sorting data in descending order is one of the most common operations in data analysis. Whether you’re identifying top-performing sales representatives, analyzing the most recent transactions, or…

Read more →
Python

PySpark - OrderBy (Sort) DataFrame

Sorting is a fundamental operation in data analysis, whether you’re preparing reports, identifying top performers, or organizing data for downstream processing. In PySpark, you have two methods that…

Read more →
Excel

How to Use SORT Function in Excel

The SORT function revolutionizes how you handle data ordering in Excel. Available in Excel 365 and Excel 2021, it creates dynamic sorted ranges that update automatically when source data…

Read more →
Pandas

How to Sort a DataFrame in Pandas

Sorting is one of the most frequent operations you’ll perform during data analysis. Whether you’re finding top performers, organizing time-series data chronologically, or simply making a DataFrame…

Read more →
Python

How to Sort a DataFrame in Polars

Sorting is one of the most common DataFrame operations, yet it’s also one where performance differences between libraries become painfully obvious. If you’ve ever waited minutes for pandas to sort a…

Read more →
Python

How to Sort Arrays in NumPy

Sorting is one of the most fundamental operations in data processing. Whether you’re ranking search results, organizing time-series data, or preprocessing features for machine learning, you’ll sort…

Read more →
Pandas

How to Sort by Index in Pandas

Pandas DataFrames maintain an index that serves as the row identifier, but this index doesn’t always stay in the order you expect. After merging datasets, filtering rows, or creating custom indices,…

Read more →
Go

Go Sort Package: Custom Sorting

Go’s standard library sort package provides efficient sorting algorithms out of the box. While sort.Strings(), sort.Ints(), and sort.Float64s() handle basic types, real-world applications…

Read more →