Browse Source

Update sort_private.odin

gingerBill 2 years ago
parent
commit
075040ae05
1 changed files with 3 additions and 2 deletions
  1. 3 2
      core/slice/sort_private.odin

+ 3 - 2
core/slice/sort_private.odin

@@ -177,7 +177,6 @@ _quick_sort_general :: proc(data: $T/[]$E, a, b, max_depth: int, call: $P, $KIND
 }
 }
 
 
 
 
-// merge sort
 _stable_sort_general :: proc(data: $T/[]$E, call: $P, $KIND: Sort_Kind) where (ORD(E) && KIND == .Ordered) || (KIND != .Ordered) #no_bounds_check {
 _stable_sort_general :: proc(data: $T/[]$E, call: $P, $KIND: Sort_Kind) where (ORD(E) && KIND == .Ordered) || (KIND != .Ordered) #no_bounds_check {
 	less :: #force_inline proc(a, b: E, call: P) -> bool {
 	less :: #force_inline proc(a, b: E, call: P) -> bool {
 		when KIND == .Ordered {
 		when KIND == .Ordered {
@@ -190,7 +189,9 @@ _stable_sort_general :: proc(data: $T/[]$E, call: $P, $KIND: Sort_Kind) where (O
 			#panic("unhandled Sort_Kind")
 			#panic("unhandled Sort_Kind")
 		}
 		}
 	}
 	}
-
+	
+	// insertion sort
+	// TODO(bill): use a different algorithm as insertion sort is O(n^2)
 	n := len(data)
 	n := len(data)
 	for i in 1..<n {
 	for i in 1..<n {
 		for j := i; j > 0 && less(data[j], data[j-1], call); j -= 1 {
 		for j := i; j > 0 && less(data[j], data[j-1], call); j -= 1 {