Don't sort a column with same values
See original GitHub issuefor a column whom all its values are the same, do not bother sorting. Touching the DOM for no reason costs in performance and if better to avoid.
Here’s a quick idea how to check if all columns values are the same:
var table = document.querySelector('table'),
rowsCount = table.rows.length,
values = {};
// lets say a user is sorting the first column
// skip the first tr which only has "th"..
while( rowsCount-- > 1){
values[ table.rows[rowsCount].children[0].textContent ] = 1;
}
// same value if the object has less than 2 keys
if( Object.keys(values).length < 2 )
return; // do not sort
Issue Analytics
- State:
- Created 8 years ago
- Comments:19 (9 by maintainers)
Top Results From Across the Web
How to prevent a column in a table from sorting
1. If you want to sort Column 1 and 3 ,you can put the column1 and 3 then select them to sort. Image...
Read more >How to Sort in Excel Rows or Columns Avoid Sort Problems
Click Custom Order. In the Sort dialog box, select the Day column in the Sort By box. From the Order drop down, select...
Read more >How to sort a column but keep intact rows in Excel?
In Excel, you can use the Sort function to sort a column and keep rows. 1. Select the column data you want to...
Read more >Disable Sorting on every column except the first one
i'm currently using Datatables for a Custom system and i would like to disable Sort for every column but the ...
Read more >In Excel, How to sort a column and keep respective values in ...
Highlight the column header (first row). In Excel 2007/2010, go to Data and click Filter. This applies a filter to each column that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I will be using tables for changing rather than sorting in the near future 💩
It took me a while but I cooked up a plugin/settings architecture and had this request implemented. See the should_redraw setting.
Thanks to everyone for the great discussion on this issue.