Sorting is the basic function of the table, and handsontable will support it.
Sometimes the requirements can be complex, require custom sorting, or call other sorting methods; custom sorting is complicated, not done; today's call to the sorting method in R.
There are two events beforecolumnsort and aftercolumnsort; Useful is the former, index,order parameter, but not supported: return false; Disables the default sorting method.
In the source code, there are several important places:
DEFAULTSORT: The default sorting method, because data and strings are mixed together in the table, want to only sort data, if typeof a[1] = = ' String ' to a[1] = infinity or return-1; The result is not ideal. It supports sorting algorithms that have problems, only 22 comparisons, and if they have the same number, they will be compared to the latter, and the sorting result will be wrong.
This.defaultsort: The next sentence is to call the sort method. If it is commented out, it will not be executed, but the icon will change.
Beforecolumnsort: Sort of event flow, can be seen clearly, the effect of each stage
Beforecolumnsort event: By setting Hot.sortorder = false; The first sort, is still small to large. There will be errors later.
Purpose: String does not participate in sorting
1, the modification defaultsort did not succeed;
2, comment out the execution of the order of the statement, sorted by R, and then refresh the data, the indicator will flash through, because the table will refresh.
Handsontable Sorting problems