I think this works - not sure how, just pasted some code I found online. It takes the Y position of 5 cubes, sorts lo-hi and outputs the cube names as string.
import c4d
# sort cubes by Y position lo-hi
# cube name output as string
def main():
global Output1, Output2, Output3, Output4, Output5
mylist = [('cube1', Input1), ('cube2', Input2), ('cube3', Input3), ('cube4', Input4), ('cube5', Input5)]
mylist.sort(key=lambda tup: tup[1]) # sort list of tuples by 2nd element lo-hi
Output1 = mylist[0][0]
Output2 = mylist[1][0]
Output3 = mylist[2][0]
Output4 = mylist[3][0]
Output5 = mylist[4][0]
https://www.dropbox.com/s/pip4h9g0ef40us8/mylist.c4d?dl=1
not very elegant, but some ideas for you.