sortC - Oppenjaimer/LbelDB.js GitHub Wiki
sortC(inx, [reverse = false])
Sort out certain column using a natural sort algorithm.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
inx | number or string |
❌ | none | Index or label of the column to sort out. |
reverse | boolean |
✔️ | false |
Whether to sort out the column in reverse order or not. |
Returns: void
Example:
const ldb = require("lbeldb");
ldb.init();
ldb.create("numbers"); // Labels: ["id", "numbers"]
ldb.addR([5]); // Rows: [ [10001, 5] ]
ldb.addR(["2"]); // Rows: [ [10001, 5], [10002, "2"] ]
ldb.addR([19]); // Rows: [ [10001, 5], [10002, "2"], [10003, 19] ]
ldb.addR(["13"]); // Rows: [ [10001, 5], [10002, "2"], [10003, 19], [10004, "13"] ]
ldb.sortC(0); // Rows: [ [10001, "2"], [10002, 5], [10003, "13"], [10004, 19] ]