This does not look very efficient with transponation, sort and transponation back, so I am happy to hear about better alternatives.
Sorting columns of data by header name
def sort_columns(table, **kwords):
return list(zip(*sorted(zip(*table), **kwords)))
table = [
['c', 'b', 'd', 'aa', 'ba', 'aab'],
list(range(2,2+6)),
list(range(6,6+6))]
for row in sort_columns(table):
print(row)
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.