Category talk:Wren-sort: Difference between revisions

m
→‎Source code: Changed a method name.
(Copied over source code from previous 'sort' module talk page.)
 
m (→‎Source code: Changed a method name.)
Line 419:
static highest(a) { highest(a, false) }
 
// Finds the medianmiddle element(s) of a sorted list.
// Returns a list of three items:
// The first item is a list of the medianmiddle element(s).
// The second item is the number of medianmiddle element(s).
// The third item is the range of indices at which the medianmiddle element(s) occur.
static medianmiddle(a) {
Sort.isList_(a)
var c = a.count
if (c == 0) Fiber.abort("An empty list does not have a medianmiddle element.")
var hc = (c/2).floor
return (c%2 == 1) ? [[a[hc]], 1, hc..hc] : [[a[hc-1], a[hc]], 2, hc-1..hc]
9,482

edits