in reply to [ Natural Sort ]: Sorting a string with numbers

One small additional facet: because the (packed) index is appended to the key, this will gave you a stable sort even if the underlying sort is unstable.

See sort for more details about what that means, and when it might be relevant.

Hugo

  • Comment on Re: [ Natural Sort ]: Sorting a string with numbers

Replies are listed 'Best First'.
Re^2: [ Natural Sort ]: Sorting a string with numbers (stable?)
by tye (Sage) on Aug 13, 2005 at 01:06 UTC

    Usually... (as bart pointed out in fast, flexible, stable sort)

    If you have fewer than 16.7 million records and none of the records contain "\0" characters, then it always works, for example.

    - tye