D
David
I'm having a bit of difficulty sorting images named in sequential order.
image1.jpg
image1.jpg
I'm having a bit of difficulty sorting images named in sequential order.
image1.jpg
I'm having a bit of difficulty sorting images named in sequential order.
image1.jpg
I need the result like so...
image1.jpg,image2.jpg,image4.jpg,image9.jpg ,image111.jpg
links.Dr John Stockton said:JRS: In article <eq6ee.28100$r81.1128@trnddc02>, dated Wed, 4 May 2005
In such cases, it is far better to arrange that the numeric part is
fixed-width, by using leading zeroes.
If there is much data, I suggest first transform it to that form, then
use a standard sort, then strip leading zeroes.
Otherwise, use a user-defined comparison function :
* Apply a RegExp to each of the comparands, splitting into letter and
number parts.
* Compare the letter parts, as strings, with > and <, returning +1 or -1
accordingly
* If not yet returned, return the difference of the numeric parts; use
of subtraction forces conversion to numbers.
Note that a comparison function is generally called more than N times in
sorting N items, so the entries will be split more than 2N times.
I don't have time to write and test code tonight.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.