examples/demo_heapsort3
raw| 1 | #!/usr/bin/env runawk |
| 2 | |
| 3 | #use "heapsort.awk" |
| 4 | |
| 5 | # This demo sorts the input lines as (key, value) pair |
| 6 | # and outputs sorted pairs. |
| 7 | |
| 8 | # Input file for this demo: examples/demo_heapsort3.in |
| 9 | |
| 10 | { |
| 11 | val = $2 |
| 12 | val += NR * 0.00001 # for regression tests |
| 13 | hash [$1] = val |
| 14 | } |
| 15 | |
| 16 | END { |
| 17 | count = heapsort_values(hash, remap) |
| 18 | |
| 19 | for (i=1; i <= count; ++i){ |
| 20 | print remap [i], int(hash [remap [i]]) |
| 21 | } |
| 22 | } |