public ArrayList<OUTTYPE> sort(HashMap<T,Double> input){
  ArrayList<Entry<T,Double>> entries=new ArrayList<Entry<T,Double>>(input.entrySet());
  Collections.sort(entries,comparator);
  ArrayList<OUTTYPE> result=new ArrayList<OUTTYPE>(entries.size());
  for (  Entry<T,Double> entry : entries)   result.add(entry.getKey());
  return result;
}

public ArrayList < OUTTYPE > sort ( HashMap < T , Double > input ) { ArrayList < Entry < T , Double > > entries = new ArrayList < Entry < T , Double > > ( input . entrySet ( ) ) ; Collections . sort ( entries , comparator ) ; ArrayList < OUTTYPE > result = new ArrayList < OUTTYPE > ( entries . size ( ) ) ; for ( Entry < T , Double > entry : entries ) result . add ( entry . getKey ( ) ) ; return result ; }
takes an element - distance map and returns the elements ordered by distance
