// Return the zero-based ascending rank of one row, breaking ties by its original index. Invalid indices return minus one. pub fn stable_rank(items: vector, index: i64) -> i64 { if index<0 || index >= len(items) { return -1; } let mut rank = 0; let mut i = 0; while i