Does anyone know of a class in Java that has a list of elements, so that the elements are sortable by any of the elements members? The idea is basically to have some database table-like implementation, where you can just add fields to sort by. To illustrate:
SomeTable table = new SomeTable();
table.addField("name", String);
table.addField("age", int);
table.addField("hair color", String);
table.add(new Object[]{"Thomas", 32, "brown"});
table.add(new Object[]{"Jack", 34, "black"});
table.sort("age") would sort the table so that Thomas is the first element, while table.sort("name") would sort the table so that Jack is the first element.
I can code something like this myself (actually i have done that once), but I'm just curious to see if there's a ready library to do such things (without a database).
PS: I know that int is not a class, but that's not the point here. This example code is just here to show the kind of functionality i expect.