This is similar to How do I use a custom comparator function with BTreeSet? however in my case I won\'t know the sorting criteria until runtime. The possible criteria are ex