Jun-17-2019, 04:14 PM
Numpy is usually for Numbers and not for strings used.
You can do this with Python itself:
You can do this with Python itself:
from itertools import chain from operator import itemgetter # your data sample_data = [ ('sample001a.com', -12, 'sample002b.com', -16, 'sample002c.com', -18), ('sample002a.com', -14, 'sample003b.com', -16, 'sample004c.com', -22), ('sample003a.com', -16, 'sample004b.com', -20, 'sample005c.com', -16), ('sample004a.com', -18, 'sample005b.com', -14), ('sample005a.com', -12), ] def sort_column(row): # ('sample003a.com', -16, 'sample004b.com', -20, 'sample005c.com', -16) # this have to be sorted # grouping host and value together group_by_two = zip(*[iter(row)]*2) # you can do this instead with indexing sorted_groups = sorted(group_by_two, key=itemgetter(1)) # group_by_two is the iterator # itemgetter get the second element from iterable (1) # the list is sorted by this value, the second value # now need to flatten the iterable # retunring it as imuatble tuple return tuple(chain.from_iterable(sorted_groups)) for row in sample_data: print(sort_column(row))How you get the data, is you task. I put an example data set in the top as a nested list.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!