[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sort -V and accents
From: |
Pierre-Jean |
Subject: |
Re: sort -V and accents |
Date: |
Wed, 01 Aug 2012 12:48:22 +0200 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Jim Meyering <address@hidden> wrote:
> Pierre-Jean wrote:
> > I'm trying to sort a file containing accents and numbers,
> > but can't find a way to do this correctly:
> The trick is to specify sorting with "-f" for the first column
> and "-V" for the second. Then it does what you seem to want:
>
> echo "
> A 10
> A 9
> E 10
> E 9
> e 10
> e 9
> é 10
> é 9
> F 10
> f 9" | sort -k1,1f -k2,2V
>
> A 9
> A 10
> e 9
> E 9
> e 10
> E 10
> é 9
> é 10
> f 9
> F 10
This is better, but still not perfect: "é 9" should be
before "e 10", like "E 9" is before "e 10", as in a
dictionnary, where "éa" is before "eb". That means that
e=E=é=è=É=È if something after makes a différence.
Look at this example:
echo "
é 9
e 10
éa
eb
E 9" | sort -k1,1f -k2,2V
E 9
e 10
é 9
éa
eb
"E 9" is correctly moved on first place, but the placement of
"é 9" doesn't follow the same law.
I probably can do with that "unperfect" order, because such
situation are not frequent in real life, but if there's a
solution, I'd be happy to know it.
> There are several examples showing how to use sort in the
> documentation. Run "info coreutils sort" to display it,
> or find it on-line:
>
> https://www.gnu.org/s/coreutils/manual/html_node/sort-invocation.html
This is nice, because I had misunderstood the usage of -k by
reading the man page.
Cheers,
Pierre-Jean.