natural sort of text and numbers, JavaScript
Posted
by ptrn
on Stack Overflow
See other posts from Stack Overflow
or by ptrn
Published on 2010-05-10T11:52:12Z
Indexed on
2010/05/10
13:14 UTC
Read the original article
Hit count: 220
I'm looking for the easiest way to sort an array that consists of numbers and text, and a combination of these.
E.g.
'123asd'
'19asd'
'12345asd'
'asd123'
'asd12'
turns into
'19asd'
'123asd'
'12345asd'
'asd12'
'asd123'
This is going to be used in combination with the solution to another question I've asked here.
The sorting function in itself works, what I need is a function that can say that that '19asd' is smaller than '123asd'.
I'm writing this in JavaScript.
Edit: as adormitu pointed out, what I'm looking for is a function for natural sorting
© Stack Overflow or respective owner