docker-alpine icon indicating copy to clipboard operation
docker-alpine copied to clipboard

sort command not working as expected

Open crashedthecymbal opened this issue 3 months ago • 0 comments

While sort on macOS and Debian is giving me the results I am looking for, alpine linux as a docker container is not sorting like expected.

Data in data.txt

2025-09-09T17:40:11 ID-01 something 2025-10-10T17:40:11 ID-01 something else 2025-10-09T17:40:11 ID-02 everything 2025-10-10T17:40:11 ID-02 everything else

cat data.txt | sort -t ';' -r -k1,2 | sort -t ';' -k2,2 -u > data_sorted.txt

The option -r (reverse) is sorting the date_time in descending order. I want to keep only the latest / newest lines with option -u (unique) .

Exoected DATA

2025-10-10T17:40:11 ID-01 something else 2025-10-10T17:40:11 ID-02 everything else

Results in Alpine linux

2025-09-09T17:40:11 ID-01 something 2025-10-09T17:40:11 ID-02 everything

Why?

I am using Alpine Linux 3.22 in a Dockerfile

FROM alpine:3.22

sort -V

BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.

Usage: sort [-nrughMcszbdfiokt] [-o FILE] [-k START[.OFS][OPTS][,END[.OFS][OPTS]] [-t CHAR] [FILE]...

Sort lines of text

crashedthecymbal avatar Sep 09 '25 20:09 crashedthecymbal