Hey, let me try explaining what i need to do with an example
Example
Before sorting
arr1 = {15,12,18,11}
arr2 = {1,2,3,4}
arr2 is always in ascending order and its length is based on the number of elements in arr1
After sorting
arr2 = {2,3,1,4}
So basically i need arr2 to show which largest number the element with the same index in arr1 is(18 is the largest so its number 1 and 12 is the 3rd largest so its number 3}
Ive tried using bubble sort but i seem to be doing something wrong, either way here is the code.
for(i = 1; i <= k; i++)
{
for(j = 0; j < k - 1; j++)
{
if(arr1[j+1] > arr1[j])
{
temp = arr2[j];
arr2[j] = arr2[j+1];
arr2[j+1] = temp;
}
}
}