Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2006
    Posts
    31

    Unanswered: largest element in an array(associative array)

    how to find the largest element in an array(associative array). The value stored is numeric?(probably without using too many loops)?

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


    try:
    Code:
    echo "${array[*]}"|tr ' ' '\n'|\
    awk '{if ( $1 > max ) {max=$1; loc=NR}}
             END {print  "Max=" max, "Loc=" loc;'

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •