add title sort after weight sort (correction)
authorcavaliet
Mon, 07 Jan 2013 15:50:28 +0100
changeset 1050 0eee72ebc2c0
parent 1049 d79a3123f31c
child 1054 54b0ac8c4a1f
add title sort after weight sort (correction)
src/ldt/ldt/ldt_utils/views/json.py
--- a/src/ldt/ldt/ldt_utils/views/json.py	Mon Jan 07 15:37:49 2013 +0100
+++ b/src/ldt/ldt/ldt_utils/views/json.py	Mon Jan 07 15:50:28 2013 +0100
@@ -163,12 +163,13 @@
                     current_weight = 1
                 
                 # Now that we have the weight for all temporal segments, we just have to sort the array.
-                highest_weighted = sorted(highest_weighted, key=itemgetter("weight", "title"), reverse=True)
+                highest_weighted = sorted(highest_weighted, key=lambda x: (-x["weight"],x["title"]))
                 for res in highest_weighted:
                     cur_in = res["start_ts"]
                     cur_out = cur_in + res["duration"]
                     if tc_in<=cur_in and cur_out<=tc_out and ((not remove_zero_dur) or (remove_zero_dur and res["duration"]>0.0)):
                         #mashup_list["items"].append(res["iri_id"] + ", " + res["element_id"] + ", " + str(res["start_ts"]) + ", " + str(res["duration"]) + ", " + str(res["weight"]))
+                        #mashup_list["items"].append(res["element_id"] + ", " + str(res["weight"]) + ", " + res["title"])
                         mashup_list["items"].append(res["element_id"])
             else:
                 # no particular sorting