ALPHA: breaking changes expected. What that means
NanoC

Sorting with callbacks

qsort with a comparison function pointer over an array of structs.

NanoC
+ <stdio.h>
+ <stdlib.h>
## Function pointers and qsort: an exact C declarator in a parameter, everything else compact.
s Person
  name: str
  age: i32
f by_age(a: *const `void`, b: *const `void`) i32
  x: *const Person = a
  y: *const Person = b
  < x->age - y->age
f main()
  team: Person[4] = {{"Ada", 36}, {"Linus", 28}, {"Grace", 45}, {"Dennis", 31}}
  qsort(team, 4, sizeof(Person), by_age)
  for i := 0; i < 4; i++
    printf("%-7s %d\n", team[i].name, team[i].age)
  < 0
C
#include <stdio.h>
#include <stdlib.h>

typedef struct Person Person;
struct Person {
    const char *name;
    int age;
};

int by_age(const void *a, const void *b) {
    const Person *x = a;
    const Person *y = b;
    return x->age - y->age;
}

int main(void) {
    Person team[4] = {{"Ada", 36}, {"Linus", 28}, {"Grace", 45}, {"Dennis", 31}};
    qsort(team, 4, sizeof(Person), by_age);
    for (int i = 0; i < 4; i++) {
        printf("%-7s %d\n", team[i].name, team[i].age);
    }
    return 0;
}

Output

stdout
Linus   28
Dennis  31
Ada     36
Grace   45

What it shows

function pointers, qsort

Edit in the playgroundSource on GitHub