Sort-filevercmp

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    Takes a list of strings and sorts them according to "filevercmp". The
    strings are pre-parsed so it may be more efficient than using
    "filevercmp" as a sort comparison function. Exported by request.

ALGORITHM

    The sort algorithm works roughly as follows:

      1. Empty strings, ., and .. go first

      2. Hidden files (strings beginning with .) go next, and are sorted
      among themselves according to the remaining rules

      3. Each string is split into sequences of non-digit characters and
      digit (0-9) characters, ignoring any filename suffix as matched by
      the regex /(?:\.[A-Za-z~][A-Za-z0-9~]*)*$/, unless the strings to be
      compared are equal with the suffixes removed.

      4. The first non-digit sequence of the first string is compared
      lexically with that of the second string, with letters (a-zA-Z)
      sorting first and other characters sorting after, ordered by
      character ordinals. The tilde (~) character sorts before all other
      characters, even the end of the sequence. Continue if the non-digit
      sequences are lexically equal.

      5. The first digit sequence of the first string is compared
      numerically with that of the second string, ignoring leading zeroes.
      Continue if the digit sequences are numerically equal.

      6. Repeat steps 4 and 5 with the remaining sequences.

CAVEATS

    This sort algorithm ignores the current locale, and has unique rules
    for lexically sorting the non-digit components of the strings, designed
    for sorting filenames. There are better options for general version
    string sorting; see "SEE ALSO".

BUGS

    Report any issues on the public bugtracker.

AUTHOR

    Dan Book <dbook@cpan.org>

COPYRIGHT AND LICENSE

    This software is Copyright (c) 2017 by Dan Book.

    This is free software, licensed under:

      The Artistic License 2.0 (GPL Compatible)

SEE ALSO

      * version - for comparing Perl version strings

      * Sort::Versions - for comparing standard version strings

      * Sort::Naturally - locale-sensitive natural sorting of mixed strings



( run in 0.779 second using v1.01-cache-2.11-cpan-56fb94df46f )