Welcome to the forum.
I read your post earlier and after thinking about it I threw together a bit of SLC500 code to show how you might tackle the problem with a sort. I only used five machines/lines in the example, you can expand the code to however many you really need.
First lets address your problem of knowing what machine has the highest and lowest count. One very simple way is to use two files. One file contains the counts, the other file contains the line number. So you copy the count for line 1 into N10:0, then you put a 1 in N11:0. Then you copy the count for line 2 into N10:1 and put a 2 in N11:2, etc. In the process of sorting, if you swap a count value you also swap the line numbers. After you have sorted then N10:0 has the lowest count and N11:0 has the number of the line with the lowest count.
First I wrote a routine for an optimized bubble sort. See ladder 3 in the attached example. In an bubble sort, after each pass there is one less item to sort. In the sort in ladder 3 after the first pass the greatest value is at the end of the array, so there is no need to to a compare on it again. To optimize it each pass makes one less comparison than the previous pass. This sort uses indirect addressing and two nested for/next loops to sort N10 and N11 in a single scan. Use ladder 3 if you absolutely have to have an up to date sort every scan, but it is heavy on overhead and has a high "WTF?" coefficient for future viewers.
After I programmed ladder 3 I read Peter's post and added a second example. See Ladder 4 in the attached. This one is a multiscan sort. It uses no indirect addressing and no looping so its low on overhead. Every scan it compares each successive pair of values in file N10, and if necessary swaps the values and the matching line numbers in N11. When a pass is completed with no swaps then we know that N10 is sorted lowest to highest and N11 gives us the matching line numbers. N10 and N11 are then copied out to N20 and N21. N20 and N21 will always contain the last sorted results, and then the process is repeated. Most of the time since only one or two counts are likely to change on any given scan, the sorted results will lag by only a few scans and never by more than N scans where N is the number of lines. If that works then go with Ladder 4, it is much simpler and I like it better. It is far less likely to result in a 3:00 am phone call from Bubba who doesn't understand loops and indirect addressing. Even if the code doesn't seem optimized, at execution time on PLC it will be more efficient than Ladder 3.
I haven't tested this code and someone may yet find something wrong with it, but hopefully it helps you. There are better ways to sort than a bubble sort but coding them on a PLC, esp. a SLC500, is a PITA and you aren't sorting a large amount of information anyways.