Return an array of all keys sorted with their values using comparator.

var map = new HashMap[String, Int]
map["ten"] = 10
map["two"] = 2
map["one"] = 1
assert map.keys_sorted_by_values(default_comparator) == ["one", "two", "ten"]
assert map.keys_sorted_by_values(alpha_comparator) == ["one", "ten", "two"]

See: to_map_comparator to get the comparator used internally.

Property definitions

core :: sorter $ MapRead :: keys_sorted_by_values
	# Return an array of all keys sorted with their values using `comparator`.
	#
	# ~~~
	# var map = new HashMap[String, Int]
	# map["ten"] = 10
	# map["two"] = 2
	# map["one"] = 1
	# assert map.keys_sorted_by_values(default_comparator) == ["one", "two", "ten"]
	# assert map.keys_sorted_by_values(alpha_comparator) == ["one", "ten", "two"]
	# ~~~
	#
	# See: `to_map_comparator` to get the comparator used internally.
	fun keys_sorted_by_values(comparator: Comparator): Array[K]
	do
		var keys = self.keys.to_a
		var map_cmp = to_map_comparator(comparator)
		map_cmp.sort(keys)
		return keys
	end
lib/core/collection/sorter.nit:280,2--298,4