sort_nat: Natural Order Sort

Sort strings in natural order.
29,4K download
Aggiornato 22 gen 2011

Visualizza la licenza

Nota dell'editore: This file was selected as MATLAB Central Pick of the Week

Natural order sorting sorts strings containing digits in a way such that the numerical value of the digits is taken into account. It is especially useful for sorting file names containing index numbers with different numbers of digits. Often, people will use leading zeros to get the right sort order, but with this function you don't have to do that. For example, with input of


a normal sort will give you


whereas, sort_nat will give you


Cita come

Douglas Schwarz (2024). sort_nat: Natural Order Sort (, MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R14SP2
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Scopri di più su Shifting and Sorting Matrices in Help Center e MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release

Fixed bug identified by Evgeny Pr. (Thanks!)

Added ability to sort in descending order.

Steve Herman identified an obscure bug (sorting a cell array of one string which has no numeric characters) which has now been fixed. Thank you Steve!

Fixed ambiguity of sort order in certain cases e.g., {'a0','a00'}. Increased speed. Relaxed MATLAB version requirements -- no longer requires R2006a, should work with much older versions now.