Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stuartlangridge/sorttable
JavaScript client-side sortable tables
https://github.com/stuartlangridge/sorttable
Last synced: 3 months ago
JSON representation
JavaScript client-side sortable tables
- Host: GitHub
- URL: https://github.com/stuartlangridge/sorttable
- Owner: stuartlangridge
- Created: 2013-05-06T18:10:09.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-01-31T19:58:31.000Z (almost 2 years ago)
- Last Synced: 2024-07-18T17:52:54.634Z (4 months ago)
- Language: JavaScript
- Size: 382 KB
- Stars: 94
- Watchers: 9
- Forks: 29
- Open Issues: 29
-
Metadata Files:
- Readme: README
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
JavaScript client-side sortable tables
See http://www.kryogenix.org/code/browser/sorttable/ for details and FAQ.
If you just want sorttable.js itself, it's in the `sorttable/` folder.
Running the tests:
grunt testTo get the test dependencies, `npm install`.
To add new tests, edit tests/test-definitions.json and add a new item to the top-level "tests" var. For example,
"basic": {
"rows": [
["1", "dog", "Adam"],
["2", "apple", "Charles"],
["3", "banana", "Bill"],
["4", "cat", "David"]
],
"expected_column_1_after_sort_by_column_n": [
["1", "2", "3", "4"],
["2", "3", "4", "1"],
["1", "3", "2", "4"]
]
}This defines (in "rows") a table with four rows and three columns. In "expected_column_1_after_sort_by_column_n" is then defined one tuple for each column; a tuple shows the contents of column 1, in order.
So, the above example has three tuples in it, one for each column. The second tuple, ["2", "3", "4", "1"], is saying that after sorting the table by the second column, we should see the *first* column containing the values "2", "3", "4", and "1", in that order.
It is advisable to make the first column of all test tables be the integers, because it makes things easier to understand, but it's not compulsory.