# Sorting lists

**URL:** https://forum.kirupa.com/t/sorting-lists/42940
**Category:** Uncategorized
**Created:** [February 14, 2004, 11:40pm UTC](https://forum.kirupa.com/t/sorting-lists/42940 "2004-02-14T23:40:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![zylum](https://avatars.discourse-cdn.com/v4/letter/z/d26b3c/32.png) [@zylum](https://forum.kirupa.com/u/zylum)
#### Post date: [February 14, 2004, 11:40pm UTC](https://forum.kirupa.com/t/sorting-lists/42940/1 "2004-02-14T23:40:02Z")

</div>

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
