Get the two highest floats in a genericList without using .Sort()?

Hello, I am trying to get two highest floats in list without Sort(). Why on earth would omseone want to do that? Well, I need to maintain the order they entered the list, so I know which number pertains to which object. And since the number is a dynamic variable I cannot simply trace it back to the original gameobject. The gameObject is being used in a equation, in which I put that number into a list.

Now Im trying to figure out how to do this. I thought I had it figured out, and coded out the possibility manually, and it kind of works, and kind of doesn’t. It’s strange, maybe using too many layers of conditional math inside single if statements. But Im hoping maybe Im overlooking an easier way.

The highest value is easy enough, but to get the two highest is… a little more complicated. Since you have to compare to previous numbers and depends if the highest was first, then you cant simply check for the next highest as, " is higher than the previous", basically. So yeah.

I don’t see any slick way but brute force:

void TwoHighest(out float highest, out float second, List<float> floats) {
	highest = Mathf.NegativeInfinity;
	second = Mathf.NegativeInfinity;
	for (int i = 0; i < floats.Count; i++) {
		if (floats *>= highest) {*
  •   		second = highest;*

_ highest = floats*;_
_ else if (floats > second) {
second = floats;

This is C#. You’d have to fiddle more to get two values out of a function in Javascript._