Understanding macOS vs Linux Sort Command Differences in Collation Behavior
By
g0xA52A2A
Pulled from the oven just right. Trustworthy, fact-dense, deeply satisfying.
Summary
The article documents a technical investigation into why the sort command produces different results on macOS versus Linux systems, even when using the same locale settings. The author discovers that macOS uses a different collation algorithm (LC_COLLATE) that treats hyphens differently than Linux systems, causing package names like 'python-dev' and 'python3-dev' to be sorted in reverse order. The article provides detailed technical analysis, code examples, and comparisons between the two operating systems' sorting behaviors.
Key quotes
· 5 pulledSame locale, different order (or technically, collation)
This is not even a difference between GNU and BSD userland; coreutils sort on macOS produces the same output as /usr/bin/sort
The difference is in the collation algorithm, not the locale data
macOS treats hyphen as a primary difference, while Linux treats it as a tertiary difference
This can cause real problems when dealing with sorted lists that need to be consistent across platforms
You might also wanna read
WSL9x: Running Modern Linux Kernel Inside Windows 9x
WSL9x is a technical project that runs a modern Linux kernel (version 6.19) cooperatively inside the Windows 9x kernel, allowing users to ru
Fuzix OS 0.4 Released with Reworked Networking Layer and Bug Fixes
Fuzix OS version 0.4 has been released with significant updates including a completely reworked networking layer for better modularity, allo
Redox OS Implements New Deficit Weighted Round Robin CPU Scheduler
The article details the implementation of a new CPU scheduler for Redox OS, replacing the legacy Round Robin scheduler with a Deficit Weight
13-Year-Old Developer Builds Complete 32-bit x86 Operating System from Scratch in 14 Days
AurionOS is a custom 32-bit x86 operating system built entirely from scratch in C and Assembly by a 13-year-old developer. The project was c
Returning to FreeBSD: A Reflection on Server Deployment Evolution
The article reflects on the evolution of server deployment methods over decades, contrasting old manual FTP/file transfer approaches with mo
hypha.pub·3mo agoGenode OS Framework: A Toolkit for Building Secure Special-Purpose Operating Systems
The Genode OS Framework is a toolkit for building highly secure special-purpose operating systems that scales from embedded systems with min
