#!/usr/bin/env runawk

#use "heapsort.awk"

# This demo sorts the input lines as (key, value) pair
# and outputs sorted pairs.

# Input file for this demo: examples/demo_heapsort3.in

{
	val = $2
	val += NR * 0.00001 # for regression tests
	hash [$1] = val
}

END {
	count = heapsort_values(hash, remap)

	for (i=1; i <= count; ++i){
		print remap [i], int(hash [remap [i]])
	}
}
