Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <inttypes.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <stdio.h>
- typedef struct data {
- int (*get_rank)(const struct data*);
- char secret[];
- } data;
- int get_rank(const data* d) {
- return (d->secret[0]);
- }
- int strcmp(const void * x1, const void * x2)
- {
- data* t1 = (data*)x1;
- data* t2 = (data*)x2;
- return ( t1->get_rank(t1) - t2->get_rank(t2));
- }
- typedef int (*comparator_t)(const void *, const void *);
- comparator_t comp = strcmp;
- void rank_sort(data* elements[], size_t size) {
- qsort(elements, size, sizeof(data*), comp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement