Skip to content

Commit 5229dd0

Browse files
author
Richard Klancer
committed
Fixed bug in sorted column table where we were inadvertently depending on query returning sorted alignment
1 parent 77d2b9e commit 5229dd0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

api/handlers.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,15 @@ def read(self, request, alignment_id, sort_cols):
9696
prerender_tds(alignment_rows, alignment)
9797

9898
keys_and_row_nums = get_keys_and_row_nums(alignment, sort_cols)
99-
sorted_rows = [alignment_rows[row_num-1] for key, row_num in sorted(keys_and_row_nums)]
99+
100+
# get a mapping from a row's 'num' attribute to its position in the alignment_rows list:
101+
i = 0
102+
num_to_index = {}
103+
for row in alignment_rows:
104+
num_to_index[row['num']] = i
105+
i+=1
106+
107+
sorted_rows = (alignment_rows[num_to_index[row_num]] for key, row_num in sorted(keys_and_row_nums))
100108

101109
response = render_to_response('api/alignment_table.html',
102110
{ 'alignment' : alignment,

0 commit comments

Comments
 (0)