Language: C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define REP(I, B, E) for (int I = (B); (I) < (E); (I)++)
#define ARRAY_LEN(A) ((long long)(sizeof((A)) / sizeof(*(A))))

int compare_int(int l, int r) {
    if (l < r) {
        return -1;
    }
    if (l > r) {
        return 1;
    }
    return 0;
}

struct City {
    char S[11];
    int P;
    int i;
};

int compare_city(const City *l, const City *r) {
    int ord = strcmp(l->S, r->S);
    if (ord != 0) {
        return ord;
    }

    ord = compare_int(r->P, l->P); // 逆順
    if (ord != 0) {
        return ord;
    }

    return compare_int(l->i, r->i);
}

int compare(const void *l, const void *r) {
    return compare_city((const City *)l, (const City *)r);
}

City cities[101];

int main(void) {
    int N;
    scanf("%d", &N);

    REP(i, 0, N) {
        char S[11];
        int P;
        scanf("%10s %d", S, &P);

        strcpy(cities[i].S, S);
        cities[i].P = P;
        cities[i].i = i;
    }

    qsort(cities, N, sizeof(City), compare);

    REP(i, 0, N) {
        printf("%d\n", cities[i].i + 1);
    }
    return 0;
}


Compiler output:
main.c:24:24: error: unknown type name 'City'
   24 | int compare_city(const City *l, const City *r) {
      |                        ^~~~
main.c:24:39: error: unknown type name 'City'
   24 | int compare_city(const City *l, const City *r) {
      |                                       ^~~~
main.c: In function 'compare_city':
main.c:25:23: error: request for member 'S' in something not a structure or union
   25 |     int ord = strcmp(l->S, r->S);
      |                       ^~
main.c:25:29: error: request for member 'S' in something not a structure or union
   25 |     int ord = strcmp(l->S, r->S);
      |                             ^~
main.c:30:24: error: request for member 'P' in something not a structure or union
   30 |     ord = compare_int(r->P, l->P); // 逆順
      |                        ^~
main.c:30:30: error: request for member 'P' in something not a structure or union
   30 |     ord = compare_int(r->P, l->P); // 逆順
      |                              ^~
main.c:35:25: error: request for member 'i' in something not a structure or union
   35 |     return compare_int(l->i, r->i);
      |                         ^~
main.c:35:31: error: request for member 'i' in something not a structure or union
   35 |     return compare_int(l->i, r->i);
      |                               ^~
main.c: In function 'compare':
main.c:39:32: error: unknown type name 'City'
   39 |     return compare_city((const City *)l, (const City *)r);
      |                                ^~~~
main.c:39:49: error: unknown type name 'City'
   39 |     return compare_city((const City *)l, (const City *)r);
      |                                                 ^~~~
main.c: At top level:
main.c:42:1: error: unknown type name 'City'; use 'struct' keyword to refer to the type
   42 | City cities[101];
      | ^~~~
      | struct 
main.c: In function 'main':
main.c:53:25: error: request for member 'S' in something not a structure or union
   53 |         strcpy(cities[i].S, S);
      |                         ^
main.c:54:18: error: request for member 'P' in something not a structure or union
   54 |         cities[i].P = P;
      |                  ^
main.c:55:18: error: request for member 'i' in something not a structure or union
   55 |         cities[i].i = i;
      |                  ^
main.c:58:29: error: 'City' undeclared (first use in this function)
   58 |     qsort(cities, N, sizeof(City), compare);
      |                             ^~~~
main.c:58:29: note: each undeclared identifier is reported only once for each function it appears in
main.c:61:33: error: request for member 'i' in something not a structure or union
   61 |         printf("%d\n", cities[i].i + 1);
      |                                 ^