[PLUG] sort option for 'natural' sequence
Paul Heinlein
heinlein at madboa.com
Tue Mar 31 15:06:15 UTC 2020
On Tue, 31 Mar 2020, Paul Heinlein wrote:
> On Tue, 31 Mar 2020, tomas.kuchta.lists at gmail.com wrote:
>
>> Everyone has different toolbox and regexp logic wired in their brains.
>> I prefer to break things down somewhat step by step - and think ahead -
>> mostly
>> it is worth it.
>
> I'm just the opposite; use the simple tool: -V option to GNU sort.
OK, that was too snarky to be helpful.
Rich,
GNU sort has a couple different options for this sort of thing. The -n
option does a basic numeric sort. It works fine on a list of basic
numbers.
The -V option is newer and was designed to sort the more complex
numeric strings in product versions. E.g., 1.0.8 should sort before
1.0.10. In fact, however, -V is very smart and will handle lots of
compound numeric strings like M/D/Y strings that aren't zero-padded
(1/8/2020 sorts before 1/10/2020).
--
Paul Heinlein
heinlein at madboa.com
45°38' N, 122°6' W
More information about the PLUG
mailing list