Martin Pool <[EMAIL PROTECTED]> writes:
| I have a functionality patch for GNU sort and ls in
|
|   http://www.linuxcare.com.au/projects/natsort/
|
| I'm not sure it's exactly the right behaviour yet, but would be
| interested to hear what you think.

Please take a look at the existing code in the latest fileutils,
especially lib/strverscmp.[ch] and ls's `--sort=version' option:

  ftp://alpha.gnu.org/gnu/fetish/fileutils-4.0q.tar.gz

Here's some documentation:

  `-v'
  `--sort=version'
       Sort by version name and number, lowest first.  It behaves like a
       default sort, excepted that each sequence of decimal digits is
       treated numerically as an index/version number.  (*Note More
       details about version sort::.)

  ...

  More details about version sort
  -------------------------------

     The version sort takes into account the fact that file names
  frequently include indices or version numbers.  Standard sorting
  functions usually do not produce the ordering that people expect
  because comparisons are made on a character-by-character basis.  The
  version sort addresses this problem, and is especially useful when
  browsing directories that contain many files with indices/version
  numbers in their names:

             > ls -1            > ls -1v
             foo.zml-1.gz       foo.zml-1.gz
             foo.zml-100.gz     foo.zml-2.gz
             foo.zml-12.gz      foo.zml-6.gz
             foo.zml-13.gz      foo.zml-12.gz
             foo.zml-2.gz       foo.zml-13.gz
             foo.zml-25.gz      foo.zml-25.gz
             foo.zml-6.gz       foo.zml-100.gz

     Note also that numeric parts with leading zeroes are considered as
  fractional one:

             > ls -1            > ls -1v
             abc-1.007.tgz      abc-1.007.tgz
             abc-1.012b.tgz     abc-1.01a.tgz
             abc-1.01a.tgz      abc-1.012b.tgz


===============================
Currently, GNU sort doesn't have an equivalent option.
If you're still interested, here are some guidelines for
adding new features:

  Here are some guidelines for contributing code to the fileutils,
  textutils, and sh-utils packages.

  Send patches. (send unified diffs, please -- i.e. diff -u format) If your
  changes fix bugs, the bar is quite low in that I don't need much more
  than to understand what the original problem was.  However, it helps
  a lot if you can give me enough information to reproduce the problem.

  On the other hand, if you're adding new features, please follow the
  guidelines below:

    - convince me that this is a useful change/addition
        (if you're adding yet another option to ls, the above is pretty hard)

    - convince other people of the same thing
        One way to do that is to post to gnu.bug.utils including as
        much description and justification as you can.  Based on the
        feedback that generates, you may be able to convince me.

  Once we agree the change is useful and get around to considering the
  actual addition to the code, it helps if you do the following:

    - base your changes on the latest test release -- currently here:
        ftp://alpha.gnu.org/gnu/fetish/

    - follow the guidelines in the GNU Coding Standards (standards.info)
        which is distributed as part of the autoconf package.

    - include changes to the texinfo documentation, and be sure to update
        the --help output.

    - finally, you'll have to send signed copyright assignment papers
        to the FSF

  And you'll have to be patient and expect delays on my part.
  It is unusual that I spend more than a few hours per week
  on the packages I maintain.

Reply via email to