material-table icon indicating copy to clipboard operation
material-table copied to clipboard

Multiple sorting

Open nlafleur opened this issue 5 years ago • 2 comments

Like someone suggested back in 2019, is it possible to have multiple sorting in the material-table?

#541 (closed)

Example: (user: cooperate) So i sort column A in this way

Col A | Col B
10        E
10         D
10         C
12         A
13         B
13         Z 
13         A

And then enable "secondary sort" and secondary sort Col B in this way

Col A | Col B
10        C
10        D
10        E
12        A
13        A
13        B
13        Z  

Thx

nlafleur avatar Mar 09 '21 09:03 nlafleur

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

stale[bot] avatar Jun 07 '21 11:06 stale[bot]

as a workaround, you can implement sorting by two properties using defaultSort and customSort on a column:

columns = {[{
  defaultSort: "asc",
  customSort: (a, b) =>
    a.foo.localeCompare(b.foo) || a.bar.localeCompare(b.bar),
...
}]}

chris-jalon avatar Oct 29 '21 15:10 chris-jalon