This option serves but is done with a list, or best can provide insight
data = []
for i, j in query.iteritems():
data.append(int(j))
try:
data.sort()
except TypeError:
del data
data_array = []
for x in data:
if x not in data_array:
data_array.append(x)
return data_array