File: demo_heapsort

package info (click to toggle)
runawk 1.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 712 kB
  • sloc: awk: 1,127; ansic: 736; sh: 420; makefile: 103
file content (19 lines) | stat: -rwxr-xr-x 301 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env runawk

#use "heapsort.awk"

# This demo sorts the input lines as strings and outputs them to stdout

# Input files for this demo: examples/demo_heapsort.in

{
	array [++count] = $0
}

END {
	heapsort(array, remap, 1, count)

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