QuickGrid: Support sorting with a custom comparer.
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
We would like to be able to sort with custom comparers, e.g., with a natural string comparer (*).
Which is possible with the current API, but it involves an item provider and custom handling of `sortBy` / `sortAscending`. See [here](https://github.com/kuba-si/AspLabs/tree/kuba/custom-comparer-existing-api-1). In the Blazor Server example, the pages that use an item provider (i.e.: "Provider" and "Virtualized") have a custom comparer which sorts country names by length rather than alphabetically:

This is too convoluted for our needs, though. We populate the grid from lightweight in-memory collections and don't use item providers.
(*) For clarity: we do have a natural string comparer implementation. The problem is that there is no easy way to plug it in.
### Describe the solution you'd like
We would like to have a simple API to specify a custom comparer for a single column. And we would like the grid itself to do the sorting. (Perhaps taking advantage of the `OrderBy` / `OrderByDescending` overloads which support custom comparers.)
See [here](https://github.com/kuba-si/AspLabs/tree/kuba/custom-comparer-new-api-1) for a working prototype for `TemplateColumn`.
And [here](https://github.com/kuba-si/AspLabs/tree/kuba/custom-comparer-new-api-2) for `PropertyColumn`.
In both cases the custom comparer (that sorts country names by length rather than alphabetically) works in the "In-memory" page:

### Additional context
_No response_
Contributor guide
Research direction
Start by reviewing the linked AspLabs prototypes for custom-comparer-new-api-1 and custom-comparer-new-api-2, covering TemplateColumn and PropertyColumn. Compare how each prototype configures the comparer and how the in-memory QuickGrid page sorts country names. Done means a simple per-column comparer API supports grid-owned ascending and descending sorting for both column types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100