CSV Sort, Done Right: Why `sort -t,` Is a Trap and What a 300-Line PHP CLI Does Instead
php
dev.to
CSV Sort, Done Right: Why sort -t, Is a Trap and What a 300-Line PHP CLI Does Instead TL;DR — Repo: https://github.com/sen-ltd/csv-sort. sort -t, looks like it sorts CSV. It doesn't. It splits on literal commas, which breaks the moment you have a quoted "Tokyo, Japan". And everything's a string, so "10" . csv-sort is a small PHP 8.2 CLI that reads CSV with fgetcsv, sorts with a type-aware comparator, writes with fputcsv. Zero Composer runtime deps. Docker image is 51 MB. 57 tests.