I'm using double commas (,,) as my array split delimiters. So, when I go to split my array, I use:
var flt = localStorage.getItem('flt');
var fltArray = new Array();
var fltArray = flt.split(",,");
When I sort the array, my sort code strips out the comma at the end of each element. So, the split between all the array elements becomes "," when it was originally ,","
I'm using the following code to sort my array.
fltOfferSellEconArray.sort(function(x,y){
var xp = x.substr(0,4);
var yp = y.substr(0,4);
return xp == yp ? 0 : xp > yp ? -1 : 1;
});
Is there a way to add a comma to the end of each element without having to loop through the array again?
Here is my array before sorting.....
["0000999X12623220000009999999999,","0300199X1392215130873ySP3sBJLTe,","0301199X1392215191700ySP3sBJLTe,","0302199X1392215252490ySP3sBJLTe,","0303199X13922153062748VplSv6axJ,","0400199X13922155681178VplSv6axJ," ,"0375199X1392215732050ySP3sBJLTe,"]
This is what I NEED it to look like after sort. (note... it just moves the element starting with "0400" to the last element.....
["0000999X12623220000009999999999,","0300199X1392215130873ySP3sBJLTe,","0301199X1392215191700ySP3sBJLTe,","0302199X1392215252490ySP3sBJLTe,","0303199X13922153062748VplSv6axJ,","0375199X1392215732050ySP3sBJLTe,","0400199X13922155681178VplSv6axJ,"]