void sort_indices()

in src/cg21/cg21_utilities.c [490:511]


void sort_indices(const char *temp, int *indices, int n)
{
    int arr[n];

    hex_to_array(temp, arr, n);

    // Initialize the indices array
    for (int i = 0; i < n; i++) {
        indices[i] = i;
    }

    // Sort the indices array based on the values in the input array
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (arr[indices[i]] > arr[indices[j]]) {
                int temp2 = indices[i];
                indices[i] = indices[j];
                indices[j] = temp2;
            }
        }
    }
}