Mottie / tablesorter

Github fork of Christian Bach's tablesorter plugin + awesomeness ~
https://mottie.github.io/tablesorter/docs/
2.61k stars 754 forks source link

Issue with Currency Sorting #476

Closed james-mckinnon closed 10 years ago

james-mckinnon commented 10 years ago

Hi there,

I'm currently using tablesorter for a project I'm working and the project manager wants the revenue column to be sorted descending by default. I believe I have followed the examples and documentation correctly but for some reason it isn't working properly.

HTML (Using Laravel Framework):

<table class="table table-bordered tablesorter revenue-sources-table">
   <thead>
      <tr>
         <th class="table-column-control tablesorter-header sorter-false"></th>
         <th class="table-column-control tablesorter-header">Overall Visits</th>
         <th class="table-column-control tablesorter-header tablesorter-headerDesc">Revenue</th>
      </tr>
   </thead>
   <tbody>
      @foreach($google_analytics_best_revenue_sources_stats as $key => $data)
         <tr>
            <td>{{ $key }}</td>
            <td>{{ $data['visits'] }}</td>
            <td>{{ $data['revenue'] }}</td>
         </tr>
      @endforeach
   </tbody>
</table>

However, when I view the table it is saying the column is being sorted descending but it is ranking £39503.02 above £55039.86.

EDIT:

Just tried it after taking the '£' symbol out and the problem is still there.

Mottie commented 10 years ago

Hi @james-mckinnon!

It seems to be working fine for me (demo)

Try setting the debug option to true and see if that column is set to use the currency parser.

james-mckinnon commented 10 years ago

Thanks for the fast response.

I completely forgot about the debug option, turns out I was passing in variables wrong elsewhere and that was breaking it.

Sorry about that.

Mottie commented 10 years ago

No worries! I'm glad it's working for you now :)