0 votes

[copied from GT FB group]

I am looking to compare 5 numbers and output the 1st and the 2nd highest! What is the best way to go about this?

What if I'm trying to output a 1st and 2nd highest, and there's a tie in myCollection.sort ie myCollection[1] = 3, myCollection[2] = 3, myCollection[3] = 1

What's the best way to output both 1st highest, and 2nd highest?

https://www.guidedtrack.com/programs/53nnjta/run

 

by (5.8k points)

1 Answer

0 votes

Put them in a collection and use myCollection.sort(“decreasing”)

Then do myCollection[1] and myCollection[2]

>> myCollection.sort(“decreasing”)
>> first = myCollection[1]
>> second = myCollection[2]

*if: first = second
    >> second = myCollection[3]

 

by (5.8k points)
Welcome to Guidedtrack Q&A, where you can ask questions and receive answers from other members of the community.
134 questions
144 answers
55 comments
40 users