# Find Greatest Number out of Variables

**URL:** <https://forum.kirupa.com/t/find-greatest-number-out-of-variables/264274>\
**Category:** flash\
**Created:** [June 24, 2008, 4:10pm UTC](https://forum.kirupa.com/t/find-greatest-number-out-of-variables/264274 "2008-06-24T16:10:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xohol](https://avatars.discourse-cdn.com/v4/letter/x/59ef9b/32.png) [@xohol](https://forum.kirupa.com/u/xohol)\
**Post date:** [June 24, 2008, 4:10pm UTC](https://forum.kirupa.com/t/find-greatest-number-out-of-variables/264274/1 "2008-06-24T16:10:24Z")

</div>

Hello all, im looking for a way to determine which number is the greatest out of a list of variables. Has anyone seen any sort of class or function that can do this?

basically i have about 10 variables that are numbers. i want to find which one has the greatest value. or which ones have the greatest tied number.

thanks for any help!

---

<div class="post-metadata">

**Author:** ![DiamondDog](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@DiamondDog](https://forum.kirupa.com/u/DiamondDog)\
**Post date:** [June 24, 2008, 4:50pm UTC](https://forum.kirupa.com/t/find-greatest-number-out-of-variables/264274/2 "2008-06-24T16:50:36Z")

</div>

If you put your values into an array (called myArray, say)  
then the largest value = arrayMaximum(myArray)  
where arrayMaximum is the following function:

```auto
function arrayMaximum(yourArray:Array):Number
{
   var maximum:Number = yourArray[0];
   for(var i:int = 1; i < yourArray.length(); i++)
   {
     if(yourArray* > maximum)
     {
       maximum = yourArray*;
     }
   }

   return maximum;
}

```

---

<div class="post-metadata">

**Author:** ![koolkrasher](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@koolkrasher](https://forum.kirupa.com/u/koolkrasher)\
**Post date:** [June 24, 2008, 5:05pm UTC](https://forum.kirupa.com/t/find-greatest-number-out-of-variables/264274/3 "2008-06-24T17:05:35Z")

</div>

I was thinking simmilar but using Array.sort(Array.NUMERIC); to make your number sory by number  
lowest to highest.

---

<div class="post-metadata">

**Author:** ![koolkrasher](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@koolkrasher](https://forum.kirupa.com/u/koolkrasher)\
**Post date:** [June 24, 2008, 5:15pm UTC](https://forum.kirupa.com/t/find-greatest-number-out-of-variables/264274/4 "2008-06-24T17:15:16Z")

</div>

Moderator kill this post and prev please my browser fed up

---

<div class="post-metadata">

**Author:** ![DiamondDog](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@DiamondDog](https://forum.kirupa.com/u/DiamondDog)\
**Post date:** [June 25, 2008, 1:24pm UTC](https://forum.kirupa.com/t/find-greatest-number-out-of-variables/264274/5 "2008-06-25T13:24:14Z")

</div>

> I was thinking similar but using Array.sort(Array.NUMERIC); to make your number sort by number lowest to highest.  
> Yes, of course.  
> That’s a neater way of doing it.  
> (I always forget there’s a sort method for arrays.)
