Code Monkey home page Code Monkey logo

Comments (8)

laurisvan avatar laurisvan commented on June 24, 2024 2

@MBilalShafi Just in order to understand the situation a wee bit better - why would the grid would need to retain the previous sort, if stable sorting is all about retaining the data across the sorting operations - not any sorting state?

Anyway, I am not personally that picky on whether it is done technically as stable sort (it just happens to be what I have done everywhere else), as long as the interaction model would not require users to learn keyboard modifiers. Our user group varies from technical experts to absolute tech illiterates, and I doubt the latter even knows which keyboard modifier to use. :)

I remember there was at some point a possilibility to sort ASC/DESC/OFF. I wonder if we could figure out a mouse operated model with these, e.g. if I first sort by one column, and then sort by another column (without clicking a modifier key), effectively still retaining the first column - at least until it is explicitly turned off?

from mui-x.

laurisvan avatar laurisvan commented on June 24, 2024 2

@MBilalShafi Thanks for your information. As a happy user of Pro version, I am glad to see this one realised one day.

from mui-x.

MBilalShafi avatar MBilalShafi commented on June 24, 2024 1

As far as I understand, instead of going with the primary and secondary only, we chose to allow the users to provide as many criteria as possible, the criteria selected first take higher priority, so in your example, if Created On is sorted first, and then Rating is sorted, the first preference will be given to the Created On which is also illustrated by the numbers assigned to each of the sort.
image

Now because the created on is never repeated, you can see no visual impact on the rating, as it's now a lower priority sort.

Instead, if you try selecting Rating first, and then Created on, you can see the rows first sorted by rating and then by created date:
image

Is your proposal to inverse this behavior, i.e. the item sorted on the last taking higher priority? Don't you think it makes more sense to keep it like the current behavior (the users can always swap the order of selection of sorts)?

from mui-x.

laurisvan avatar laurisvan commented on June 24, 2024 1

@MBilalShafi Let me be clear on what I suggest with the same pictures you have mentioned using good old MS Excel that might be the most widely used "grid editor".

Plese note that this does not require any special data structures - it only requires that the sorted elements are retained in state, and that when the order is changed, the elements in the state are reordered. Unfortunately I do not know enough of MUI internals that I could point to where the problem might be. But as it fails in your example page, I believe the problem might be specific to the UI component (as mentioned before JavaScript Array.sort is at least claimed to be stable).

  1. Initially these people are ordered by name (not relevant in this example)
Screenshot 2023-11-02 at 8 12 51
  1. When selecting Sort By "Created on" (desc), the items get ordered from most recent to newest.
Screenshot 2023-11-02 at 8 13 08 Screenshot 2023-11-02 at 8 13 19
  1. When selecting Sort By "Rating", the items get ordered by rating.

Current & expected outcome: *Please pay close attention to "Created on" - they remain ordered by date within the rating groups (the most recent 5-start item appears first, e.g. 24.10. appears before 12.10.). This is not a coincidence, but stable sorting.
Screenshot 2023-11-02 at 8 33 23

Now, when repeating the same pattern with the MUI Grid example:

  1. The initial order is whatever it might be (in this case Name DESC)
Screenshot 2023-11-02 at 8 14 42
  1. I sort by "Created on" DESC
Screenshot 2023-11-02 at 8 19 03
  1. I Sort by "Rating" DESC
Screenshot 2023-11-02 at 8 15 29

When scrolling down, I see':

Screenshot 2023-11-02 at 8 19 21

Current outcome: The previous sort order is not retained, at least fully - the order of "Created on" is messed up within the same 5-star rating groups
Expected outcome: The previous sort order would be retained

from mui-x.

DanailH avatar DanailH commented on June 24, 2024

@mui/xgrid Can someone help here? I don't think there is a concrete thing that we can do but rather understand the decision we took when we did the multi-sorting feature.

from mui-x.

MBilalShafi avatar MBilalShafi commented on June 24, 2024

Ah I see, thanks for the detailed example, now I understand your request.

For the grid, you can achieve the same by multiple sort criterion as I mentioned in my first comment, the grid doesn't retain the previous sort for the column from which the sort has been removed, that's a design choice we took while implementing sorting and I think it makes sense too because more freedom is available to users to define any sort priority/order using multi-sorting. (For a benchmark, AgGrid also behaves in a similar fashion)

@mui/xgrid What do you think?

from mui-x.

cherniavskii avatar cherniavskii commented on June 24, 2024

Would it make sense to add an option for changing the default sorting behavior to multi-sorting?

from mui-x.

MBilalShafi avatar MBilalShafi commented on June 24, 2024

why would the grid would need to retain the previous sort, if stable sorting is all about retaining the data across the sorting operations - not any sorting state

You are correct, when I mentioned "the grid doesn't retain the previous sort", technically I meant the same, the wording might be confusing. Tbh, I feel your request makes sense.

We discussed and decided to consider the stable sort as a Pro option alongside multi-sorting. Please keep checking this issue for further updates.

from mui-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.