View Full Version : Sorting Numeric Text in Column
skhealy
11 Jan 2011, 8:14 AM
Hey All,
Is there a way to sort numeric text in an appropriate fashion (and not like 10,109,21,240,3)?
Thanks,
SKH
are you setting the field as type : 'INT" ?
skhealy
13 Jan 2011, 5:59 AM
No...as a string...was kind of hoping there would be a way to handle this with a configuration option. I tried setting the sortType in the fields configuration object to 'asInt', but it had no effect.
try this simple sorter:
function sortNumber(a,b) {
return b - a;
}
var n = ["10", "5", "40", "25", "100", "1"];
console.log(n.sort(sortNumber));
skhealy
13 Jan 2011, 7:03 AM
Okay...where or how do I implement this sorter? I have a JsonStore with dates, alphanumeric data and numbers (all received as strings) that feeds a grid on a report page. I was able to get the dates to sort by setting the dateFormat property to "m/d/Y' within the JsonStore. Where or how do I configure this sorter to apply only to the number fields?
Powered by vBulletin® Version 4.2.3 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.