MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / ref_stable_order

Function ref_stable_order

tests/test_cypher.c:5634–5645  ·  view source on GitHub ↗

The reference order: an insertion sort that moves a row before an earlier * one only when the earlier one compares greater — stable, like the old * bubble sorts. */

Source from the content-addressed store, hash-verified

5632 * one only when the earlier one compares greater — stable, like the old
5633 * bubble sorts. */
5634static void ref_stable_order(const cbm_cypher_result_t *r, int *order, ref_cmp_fn cmp) {
5635 for (int i = 0; i < r->row_count; i++) {
5636 order[i] = i;
5637 }
5638 for (int i = 1; i < r->row_count; i++) {
5639 for (int j = i; j > 0 && cmp(r, order[j - 1], order[j]) > 0; j--) {
5640 int swap = order[j];
5641 order[j] = order[j - 1];
5642 order[j - 1] = swap;
5643 }
5644 }
5645}
5646
5647/* Columns 0 (name) and 1 (line): line descending, then name ascending. */
5648static int ref_line_desc_name(const cbm_cypher_result_t *r, int a, int b) {

Callers 1

ref_rows_in_orderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected