| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 2 | |
I have a situation where I'm sorting a (large) list of strings for display that sometimes are numbers, sometimes character data and sometimes both. There has been work done on string comparisons that compare the sub-strings of all-characters or all numeric data so you get a more "natural ordering" i.e. a list of strings sorted with a regular string sort would be a1 a10 a100 a11 a2 a20 a5 a9 where as the natural sorting would produce the more desirable a1 a2 a5 a9 a10 a20 a100 The concept and code is fairly simple and there are multiple implementations, probably the most robust being: http://sourcefrog.net/projects/natsort/ Before coding it up myself to work with QStrings and qSort/qStableSort I was wondering if anybody had the code snippet lying around and would like to share? -- [ signature omitted ]
On Wednesday 12 December 2007 16:38:30 Gabe F. Rudy wrote: > Before coding it up myself to work with QStrings and qSort/qStableSort I > was wondering if anybody had the code snippet lying around and would > like to share? Take a look at KCategorizedSortFilterProxyModel::naturalCompare at http://websvn.kde.org/trunk/KDE/kdelibs/kdeui/itemviews/kcategorizedsortfilterproxymodel.cpp?view=markup -- [ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.