boliva Posted June 22, 2022 Share Posted June 22, 2022 Is there a way to easily find the second highest or third highest value in an array? I know I can use Max/Min, but not sure if I wanted to find the two highest values how to find the next easily? Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 22, 2022 Share Posted June 22, 2022 Well, there isn't a built in function for this like min2() or min(val, 2) or something, but it is not hard to do using boolean math, especially if all the values are > 0. You'd basically have to iterate through, removing values as you go using boolean math: private themax = max(myArray) private themax2 = max(myArray * (myArray < themax)) private themax3 = max(myArray * (myArray < theMax2)) etc... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.