Implement normalize(list, idKey)
The shape behind every "normalized state" Redux store (and RTK's entityAdapter): an array of records, reshaped into fast-lookup form. Write normalize(list, idKey) that returns { byId, allIds }:
byId, an object mapping each record'sidKeyvalue to the record itself.allIds, an array of the ids, in the original order (this is what preserves list ordering once you're indexing by id).
normalize([{ id: "a", name: "Ada" }, { id: "b", name: "Grace" }], "id");
// { byId: { a: {id:"a",name:"Ada"}, b: {id:"b",name:"Grace"} }, allIds: ["a", "b"] }