shithub: mc

Download patch

ref: a64576667fa432665cf01edfbb24658135351c54
parent: 996f8ee34ea615532312cb67df423ad48e2e4278
author: Ori Bernstein <[email protected]>
date: Sun Sep 14 21:45:37 EDT 2014

Fix typo in sort.

    We were using the wrong array length.

--- a/libstd/sort.myr
+++ b/libstd/sort.myr
@@ -15,7 +15,7 @@
 		sl[end] = sl[0]
 		sl[0] = tmp
 		end--
-		siftdown(sl[:end], 0, cmp)
+		siftdown(sl[:end + 1], 0, cmp)
 	;;
 	-> sl
 }
--- a/test/data/stdsort-expected
+++ b/test/data/stdsort-expected
@@ -1,6 +1,6 @@
 0
-2
 1
+2
 3
 4
 5
@@ -8,6 +8,7 @@
 7
 8
 9
+---
 1
 2
 3
@@ -18,6 +19,7 @@
 8
 9
 10
+---
 C
 Cc
 a
--- a/test/stdsort.myr
+++ b/test/stdsort.myr
@@ -15,10 +15,12 @@
 	for v in a
 		std.put("%i\n", v)
 	;;
+	std.put("---\n")
 	std.sort(b[:], std.numcmp)
 	for v in b
 		std.put("%i\n", v)
 	;;
+	std.put("---\n")
 	std.sort(c[:], std.strcmp)
 	for v in c
 		std.put("%s\n", v)