1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 17:24:50 +01:00

23660: fix numerical sorting of parameters + tests + documentation

This commit is contained in:
Peter Stephenson 2007-07-06 13:10:43 +00:00
parent e8458f44c4
commit ccc2e1bd89
4 changed files with 18 additions and 8 deletions

View file

@ -1,5 +1,9 @@
2007-07-06 Peter Stephenson <pws@csr.com>
* 23660: Doc/Zsh/expn.yo, Src/sort.c, Test/D04parameter.ztst:
numerical sorting didn't work in reverse, wasn't tested and wasn't
correctly documented.
* unposted: Functions/Calendar/calendar_lockfiles: configuration
appears to reduce collisions between lock attempts in multiple
windows.

View file

@ -764,13 +764,12 @@ item(tt(L))(
Convert all letters in the result to lower case.
)
item(tt(n))(
Sort decimal numbers numerically; if the first differing
Sort decimal integers numerically; if the first differing
characters of two test strings are not digits, sorting
is lexical. Numbers with initial zeroes
are sorted before those without. Hence the array `tt(foo1 foo02
foo2 foo3 foo20 foo23)' is sorted into the order shown. Trailing
non-digits are not sorted; the order of `tt(2foo)' and `tt(2bar)'
is not defined. May be combined with `tt(i)' or `tt(O)'.
is lexical. Integers with more initial zeroes
are sorted before those with fewer or none. Hence the array `tt(foo1 foo02
foo2 foo3 foo20 foo23)' is sorted into the order shown.
May be combined with `tt(i)' or `tt(O)'.
)
item(tt(o))(
Sort the resulting words in ascending order; if this appears on its

View file

@ -134,9 +134,9 @@ eltpcmp(const void *a, const void *b)
while (idigit(*as) && idigit(*bs))
as++, bs++;
if (idigit(*as) && !idigit(*bs))
return 1;
return sortdir;
if (idigit(*bs) && !idigit(*as))
return -1;
return -sortdir;
}
}
}

View file

@ -913,3 +913,10 @@
>AXB C1D
>AB C0D
>AB C0D
foo=(a6 a117 a17 b6 b117 b17)
print ${(n)foo}
print ${(On)foo}
0:Numeric sorting
>a6 a17 a117 b6 b17 b117
>b117 b17 b6 a117 a17 a6