RECENT POSTS
- Introduction to FreeBSD Security Best Practices
- Working with Package Management in FreeBSD
- Understanding FreeBSD Security Advisories and Updates
- Troubleshooting Common System Administration Issues in FreeBSD
- Tips for Hardening FreeBSD to achieve System Protection
- Setting Up DHCP Server in FreeBSD
- Secure User and Group Management in FreeBSD Systems
- Secure Remote Access with SSH in FreeBSD
- Optimizing System Performance in FreeBSD
- Network Packet Capture with tcpdump in FreeBSD
- All posts ...
Do you have GDPR compliance issues ?
Check out Legiscope a GDPR compliance software, that will save you weeks of work, automating your documentation, the training of your teams and all processes you need to keep your organisation compliant with privacy regulations
P5-sort-naturally
Jul 20, 2023
Sort lexically, but sort numeral parts numerically
This module exports two functions, nsort and ncmp; they are used in implementing my idea of a “natural sorting” algorithm. Under natural sorting, numeric substrings are compared numerically, and other word-characters are compared lexically.
This is the way I define natural sorting
* Non-numeric word-character substrings are sorted lexically, case-insensitively "Foo" comes between "fish" and "fowl".
* Numeric substrings are sorted numerically "100" comes after "20", not before.
* \W substrings neither words-characters nor digits are ignored. Our use
* of \w, \d, \D, and \W is locale-sensitive SortNaturally uses a use locale statement.
* When comparing two strings, where a numeric substring in one place is not up against a numeric substring in another, the non-numeric always comes first. This is fudged by reading pretending that the lack of a number substring has the value -1, like so
* The start of a string is exceptional leading non-\W non-word, non-digit components are ignored, and numbers come before letters.
* I define "numeric substring" just as sequences matching m/\d+/ -- scientific notation, commas, decimals, etc., are not seen. If your data has thousands separators in numbers "20,000 Leagues Under The Sea" or "20.000 lieues sous les mers", consider stripping them before feeding them to nsort or ncmp.
- Older
- Newer
Checkout these related ports:
- Zxing-cpp - ZXing C++ Library for QR code recognition
- Zu-hunspell - Zulu hunspell dictionaries
- Zu-aspell - Aspell Zulu dictionary
- Zq - Easier and faster alternative to jq
- Zorba - General purpose C++ XQuery processor
- Zenxml - Simple C++ XML Processing
- Zed - Command-line tool to manage and query Zed data lakes
- Yq - Command-line YAML and XML processor, jq wrapper for YAML/XML documents
- Yould - Pronounceable word generator
- Yodl - Easy to use but powerful document formatting/preparation language
- Yi-hunspell - Yiddish hunspell dictionaries
- Yi-aspell - Aspell Yiddish dictionary
- Yelp-xsl - DocBook XSLT stylesheets for yelp
- Yelp-tools - Utilities to help manage documentation for Yelp and the web
- Ydiff - Diff readability enhancer for color terminals