Sorting lists

ok so i have 2 arrays, a and b… in array a i have a bunch of random numbers… now i want to loop through array a find which of the elements is the largest. for example if a[4] is the largest number in the a[] then i want b[1] = 4 and so on… its kind of hard to explain -_-

here’s an example of what i want…

//array a full of random numbers:
a[1] = 4
a[2] = 3
a[3] = 1
a[4] = 8
//array b with assigned values
b[1] = 4
b[2] = 1
b[3] = 2
b[4] = 3

so if a[4] is the bigest, b[1] will have 4 and if a[1] is second biggest, b[2] will have 1 and so on… is there an algorithm that can do this for me with an array length of X???

-zylum