Skip to content

natsort

strings · scripts/strings/natsort.m

[Y, I] = natsort (C)
[Y, I] = natsort (C, direction)

Natural / human sort of text (filenames, labels with embedded numbers).
Digit runs compare numerically so "file2" sorts before "file10".
C may be a cell array of character vectors, a string array, or a char
row.  Direction is "ascend" (default) or "descend".