Muhanad Muneer
Muhanad Muneer

Reputation: 13

Wrong sorting decimal values tablesorter script

I have problem while sorting decimal values table sorter grid. When I try to sort distance values in the table the distance sort as follows :

distance
0.35
0.76
1.36
1.75
10.36
100.66
2.33

$(document).ready(function() {
// extend the default setting to always include the zebra widget.
$.tablesorter.defaults.widgets = ['zebra'];
// extend the default setting to always sort on the first column
$.tablesorter.defaults.sortList = [[0,0]];
$.tablesorter.defaults.debug=true;
  $("table#list").tablesorter();
  });
  $(document).ready(function() {

    $("table#list").tablesorterPager({container: $("#pager")});
    });

Can any one tell me what's the solution to prevent wrong sorting ?

Upvotes: 0

Views: 2125

Answers (1)

Mottie
Mottie

Reputation: 86433

Try setting the sorter to digit in the header option:

$(function() {
  $("table#list").tablesorter({
    widgets  : ['zebra'],
    sortList : [[0,0]]
    headers  : {
      0 : { sorter : 'digit' }
    }
  }).tablesorterPager({
    container: $("#pager")
  }); 
});

Upvotes: 2

Related Questions