I have a JS object, with an internal array of another JS object. The internal onw is like
function outerObj()
{
this.items = new Array();
this.clear = function () {
this.items = new Array();
}
function __item(v1, v2, v3, v4) {
this.Val_1 = v1;
this.Val_2 = v2;
this.Val_3 = v3;
this.Val_4 = v4;
}
this.add = function (vA, vB, vC, vD) {
this.items.push( new __item(vA, vB, vC, vD) );
}
...
}
The array is loaded through an SPServices getListItems()
call, using .each( . . . )
on the resultant XML. The results are ordered (<OrderBy>
), but the results are the common irritation:
1
10
11
2
21
3
42A
42B
I cannot get away from the inclusion of letters (this is the name of real-world items), while I want the sort to be
1
2
3
10
11
21
42A
42B
Suggestions?
Just use javascript array.sort()
code would look like this:
this.items.sort()
Heres a link: Javascript sort reference