29 users online (1 members and 28 guests)  


  Results 1 to 2 of 2

Related

  1. Replies: 4
  2. table row values    Forum: HTML Forum
    Replies: 1
  3. Hashes lose values.    Forum: CGI Perl Forum
    Replies: 0
  4. adding up my values    Forum: Javascript Forum
    Replies: 1
  1. #1
    blink's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2005
    Posts
    19

    Getting min/max values from an array

    Hello!

    If I have constructed an array in the following manner:

    @myvalues = (1,2,3,4,5);

    How do I find out what the lowest and highest numbers in the array are?

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662

    Re: Getting min/max values from an array

    Hiya,

    Easiest I have found is to sort the array normally, grab the first element. Thats your highest. Then sort reverse, grab first, thats your lowest.

    Theres some good examples here: http://www-cgi.cs.cmu.edu/Web/People/rgs/pl-exp-arr.html
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread