Open
Description
Hello,
I am using createEntityAdapter
on my app, and I need to sort the entities I got from the server, using many different sort functions.
Currently, createEntityAdapter
only supports a single ids
array and a single sortcomparer
.
I managed this by making different selectors which get the sorted entities array (using selectAll
) from the reducer and sort it in a different way.
However, it is not normalized structure since I can't get a sorted ids, but sorted entities.
Is there any way to have multiple ids
arrays with a single entities
lookup table?
For example,
type Book = { bookId: string; title: string; author: string }
const booksAdapter = createEntityAdapter<Book>({
selectId: (book) => book.bookId,
// ids arrays sorted based on book titles, and also on **author names**.
sortComparer: [
sortFuncByTitleAsc,
sortFuncByAuthorAsc,
],
})
Thanks.