I have a list of objects I need to sort according to properties of one of their fields. I\'ve heard that SortedMap and Comparators are the best way to do this.
My answer assumes you are using the TreeMap implementation of SortedMap.
1.) If using TreeMap, you have a choice. You can either implement Comparable directly on your class or pass a separate Comparator to the constructor.
2.) Example:
Comparator cmp = new MyComparator();
Map map = new TreeMap(myComparator);
3.) Yes that's correct. Internally TreeMap uses a red-black tree to store elements in order as they are inserted; the time cost of performing an insert (or retrieval) is O(log N).