This is an ordered linked map (like a double linked list) with items reachable by key.
import { SortedLinkedMap } from "sorted-linked-map";
type UserType = {
id: string;
name: string;
age: number;
};
const list = new SortedLinkedMap<string, UserType>(
(value) => value.id,
(a, b) => (a.age < b.age ? -1 : 1)
);
list.add({
id: "john.doe",
age: 35,
name: "John Doe",
});
list.add({
id: "john.smith",
age: 28,
name: "John Smith",
});