No, it's not possible (well, technically it's not impossible, but it would be a huge kludge with reflection, and a very bad idea). If you have a separate Comparator
for all your different sort options (provided that there are only a handful, maybe 5-10 cases), you have a nice strongly typed system in place.
Besides, if the name is ID_SORT
, why would you have it sort by anything besides the ID? It would be confusing to anyone using the code.