Sort table using certain order
Sort table using certain order
islamelshobokshy
Posts: 99Questions: 20Answers: 1
I've got these values :
AH 18, AH 17, AH 16, AH 15, PE 18, PE 17, PE 16, PE 15... etc
I want to be able to sort them, by clicking on the appropriate button, to this order :
AH 18, PE 18, AH 17, PE 17, AH 16, PE 16, AH 15, PE 15
How can I achieve that? I know how to manipulate order using this, this works as it orders them using numbers by removing the space and everything before, but by doing that I get PE 18, AH 18, PE 17, AH 17 ... etc
and not the right order I want it to be.
columnDefs.push({"type": "num-fmt", "targets": i});
columnDefs.push({
"targets": i,
"render": function ( data, type, row, meta ) {
return type === 'sort' ?
data.replace(/.*\s/g,'') : data;
}
});
Help ?
This discussion has been closed.
Replies
Sounds like you want to order by number first then the letters. I would first try swapping the order within the sort type, something like this:
18AH, 17AH, 16AH, 15AH, 18PE, 17PE...
Kevin
Gold, thanks @kthorngren !