Property definitions

core $ MapComparator :: defaultinit
# A comparator that compares things with their values in a map.
#
# ~~~
# var map = new HashMap[String, Int]
# map["ten"] = 10
# map["two"] = 2
# map["one"] = 1
#
# var map_cmp = map.to_map_comparator(default_comparator)
# var a = ["ten", "one", "two"]
# map_cmp.sort(a)
# assert a == ["one", "two", "ten"]
# map_cmp = map.to_map_comparator(alpha_comparator)
# map_cmp.sort(a)
# assert a == ["one", "ten", "two"]
# ~~~
class MapComparator[K,V]
	super Comparator

	# What is compared are the keys of the values
	redef type COMPARED: K

	# The map that associates compared elements to the value used to compare them
	var map: MapRead[K,V]

	# The comparator used to compare values
	var comparator: Comparator

	redef fun compare(a,b) do return comparator.compare(map[a], map[b])
end
lib/core/collection/sorter.nit:306,1--335,3