Sort a custom column type
This demo shows how to implement your own sorter for a custom column type.
The sort
extension provides a public interface for implementing
custom sorter functions.
Custom type | Id | Phone | € | US $ | Url | EU Date | US Date | |
---|---|---|---|---|---|---|---|---|
devo@flexomat.com | AUY78 | 66672 | 941-964-8535 | 2.482,79 | 2,482.79 | http://gmail.com | 14/12/1988 | 12/14/1988 |
henry@mountdev.net | QT2 | 35889 | 941-964-9543 | 2.776,09 | 2,776.09 | http://www.gmail.com | 19/1/1984 | 1/19/1984 |
christian@reno.gov | QT1 | 60021 | 941-964-5617 | 2.743,41 | 2,743.41 | http://www.dotnet.ca | 25/3/2000 | 3/25/2000 |
muffins@donuts.com | QT1T | 17927 | 941-964-9511 | 2.998,18 | 2,998.18 | http://google.se | 24/1/1993 | 1/24/1993 |
muffins@reno.gov | QT28 | 76375 | 941-964-2757 | 1.836,09 | 1,836.09 | http://www.samba.org | 4/4/1988 | 4/4/1988 |
mendez@gmail.com | JH9 | 45834 | 941-964-2575 | 2.805,46 | 2,805.46 | http://flexomat.com | 12/12/1985 | 12/12/1985 |
dev@gmail.com | QT3 | 20022 | 941-964-4967 | 3.296,54 | 3,296.54 | http://www.flexomat.com | 3/7/2002 | 7/3/2002 |
foo@polyester.se | YU899 | 55987 | 941-964-745 | 2.953,73 | 2,953.73 | http://www.donuts.com | 4/8/1987 | 8/4/1987 |
adam@aftonbladet.se | QT122 | 38867 | 941-964-6302 | 1.949,27 | 1,949.27 | http://flexomat.com | 27/7/1995 | 7/27/1995 |
devo@donuts.com | QT10 | 51426 | 941-964-1234 | 1.067,00 | 1,067.00 | http://www.polyester.se | 5/1/1986 | 1/5/1986 |
henry@samba.org | TY76 | 40859 | 941-964-4856 | 3.401,19 | 3,401.19 | http://www.flexomat.com | 7/3/1990 | 3/7/1990 |
found@dotnet.ca | DF43 | 23986 | 941-964-2686 | 1.393,52 | 1,393.52 | http://lostnfound.org | 22/7/1993 | 7/22/1993 |
carl@fish.org | IU90 | 73392 | 941-964-5792 | 3.876,04 | 3,876.04 | http://www.google.se | 14/7/1984 | 7/14/1984 |
found@mountdev.net | VX113 | 03519 | 941-964-1599 | 1.176,48 | 1,176.48 | http://donuts.com | 6/8/2000 | 8/6/2000 |
lost@fish.org | ZP82 | 36628 | 941-964-5985 | 822,23 | 822.23 | http://www.gmail.com | 14/7/1994 | 7/14/1994 |
mendez@dotnet.ca | OK33 | 90442 | 941-964-1649 | 1.985,72 | 1,975.72 | http://reno.gov | 20/10/1997 | 10/20/1997 |
carl@donuts.com | EQ97 | 00412 | 941-964-6432 | 1.834,77 | 1,834.77 | http://gmail.com | 23/8/1997 | 8/23/1997 |
foo@fish.org | FS56 | 80653 | 941-964-1022 | 260,26 | 260.26 | http://samba.org | 24/11/1991 | 11/24/1991 |
found@fish.org | MW3 | 54635 | 941-964-6439 | 1.442,80 | 1,442.80 | http://dotnet.ca | 12/7/1987 | 7/12/1987 |
found@flexomat.com | RE51 | 20953 | 941-964-5544 | 575,42 | 575.42 | http://gmail.com | 10/6/1988 | 6/10/1988 |
The
addSortType
method accepts the following paremeters:
- an identifier of the sort type (lowercase)
- an optional function that takes a string and casts it to a desired format, if not specified it returns the string itself
- an optional compare function taking 2 values and compares them. If not specified defaults to `less than compare` type