joequery/Stupid-Table-Plugin

How is it sorting when all the values are equal.

Opened this issue · 4 comments

I have a table as below. When I am sorting based on the final column which has all the values equal, Intuitively it shall not sort. But why is it changing the order.

      <tr>
        <td>
          <a href="/downloads/handbook/1-data-analysis-1.pdf">
            1-data-analysis-1
          </a>
        </td>
        <td>.PDF</td>
        <td data-sort-value="1222503">1.2MB</td>
        <td data-sort-value="1405701839.0">Fri 18-Jul-2014</td>
      </tr>
    
      
      <tr>
        <td>
          <a href="/downloads/handbook/7-dashboard-design.pdf">
            7-dashboard-design
          </a>
        </td>
        <td>.PDF</td>
        <td data-sort-value="1381537">1.4MB</td>
        <td data-sort-value="1405701839.0">Fri 18-Jul-2014</td>
      </tr>
    
      
      <tr>
        <td>
          <a href="/downloads/handbook/6-better-design.pdf">
            6-better-design
          </a>
        </td>
        <td>.PDF</td>
        <td data-sort-value="1013217">1.0MB</td>
        <td data-sort-value="1405701839.0">Fri 18-Jul-2014</td>
      </tr>
    
      
      <tr>
        <td>
          <a href="/downloads/handbook/4-designing-visualisations.pdf">
            4-designing-visualisations
          </a>
        </td>
        <td>.PDF</td>
        <td data-sort-value="2142352">2.1MB</td>
        <td data-sort-value="1405701839.0">Fri 18-Jul-2014</td>
      </tr>
    
      
      <tr>
        <td>
          <a href="/downloads/handbook/5-visual-representations.pdf">
            5-visual-representations
          </a>
        </td>
        <td>.PDF</td>
        <td data-sort-value="3025762">3.0MB</td>
        <td data-sort-value="1405701839.0">Fri 18-Jul-2014</td>
      </tr>
    
      
      <tr>
        <td>
          <a href="/downloads/handbook/0-introduction.pdf">
            0-introduction
          </a>
        </td>
        <td>.PDF</td>
        <td data-sort-value="194396">0.2MB</td>
        <td data-sort-value="1405701839.0">Fri 18-Jul-2014</td>
      </tr>
    
      
      <tr>
        <td>
          <a href="/downloads/handbook/2-data-analysis-2.pdf">
            2-data-analysis-2
          </a>
        </td>
        <td>.PDF</td>
        <td data-sort-value="456043">0.5MB</td>
        <td data-sort-value="1405701839.0">Fri 18-Jul-2014</td>
      </tr>
    
      
      <tr>
        <td>
          <a href="/downloads/handbook/3-data-stories.pdf">
            3-data-stories
          </a>
        </td>
        <td>.PDF</td>
        <td data-sort-value="625371">0.6MB</td>
        <td data-sort-value="1405701839.0">Fri 18-Jul-2014</td>
      </tr>
    
  
  
</tbody>
File Type Size Date

I have also come across this issue and would appreciate a solution for this. Will it be fixed?

Well, you can force your sorting adding a data-sort-value attribute in which you can join date in mysql format (yyyy-mm-dd) to, for example, file name.
So at first sort, when all dates are equal, the table is sorted by file name ASC, and with a second sort by date the table is sorted by file name DESC.
Or you can use a row progressive id...

Sorry, I missed this issue!

Intuitively it shall not sort.

To an extent I see your point, although I personally don't find the behavior intuitive.

I think you can modify the plugin to check for equality among all values in the column being sorted before sorting.

So right here in the source would be a good spot to iterate over the column array-of-arrays and see if the first element(the sort value) of each inner array is equal.

This behavior may cause issues in some small instances, but I don't think it's enough to make its way into the source. I want to keep the plugin stupid. I hope the source is readable enough for anyone to make modifications to accommodate their specific needs.

If you need help making the source modifications I'd be happy to assist :)

I'll try to provide the modification necessary to fix this issue if I can find enough time.