mirror of
https://github.com/not-kennethreitz/convore.json.git
synced 2026-06-21 15:40:58 +00:00
1 line
2.8 KiB
JSON
1 line
2.8 KiB
JSON
[{"user_id": 3580, "stars": [], "topic_id": 13418, "date_created": 1300310654.0108509, "message": "for i in merged(a,b, fields=('-updated_date', '-id')):\n print i", "group_id": 81, "id": 369569}, {"user_id": 3580, "stars": [], "topic_id": 13418, "date_created": 1300310513.074724, "message": "A couple times I've run into situations where I have a couple of sequences (usually Django queryset instances) that I want to merge together, and retain order...", "group_id": 81, "id": 369548}, {"user_id": 3580, "stars": [], "topic_id": 13418, "date_created": 1300310538.677319, "message": "so like a = EntityA.objects.order_by('-updated_date', '-id')", "group_id": 81, "id": 369552}, {"user_id": 3580, "stars": [], "topic_id": 13418, "date_created": 1300310553.6004839, "message": "b = EntityB.objects.order_by('-updated_date', '-id')", "group_id": 81, "id": 369555}, {"user_id": 3580, "stars": [], "topic_id": 13418, "date_created": 1300310566.349159, "message": "so I came up with this relatively hairy generator: http://pastie.org/private/g68xcshe3rtwikzaqb99nq", "group_id": 81, "id": 369558}, {"user_id": 3580, "stars": [], "topic_id": 13418, "date_created": 1300310653.318306, "message": "which allows me to do:", "group_id": 81, "id": 369568}, {"user_id": 3580, "stars": [], "topic_id": 13418, "date_created": 1300310685.276336, "message": "there's a couple things I don't like about it (it fails if your sequences contain None, for instance)..", "group_id": 81, "id": 369571}, {"user_id": 3580, "stars": [], "topic_id": 13418, "date_created": 1300310704.0682051, "message": "but yeah.. wondering if there's a better pattern/library/recipe for doing this?", "group_id": 81, "id": 369574}, {"user_id": 3580, "stars": [], "topic_id": 13418, "date_created": 1300310783.7989399, "message": "I guess I'm also curious if this is a need other folks run into as regularly as I seem to :)", "group_id": 81, "id": 369580}, {"user_id": 7, "stars": [{"date_created": 1300466617.6730421, "user_id": 1296}], "topic_id": 13418, "date_created": 1300326349.970612, "message": "http://docs.python.org/library/heapq.html#heapq.merge", "group_id": 81, "id": 370775}, {"user_id": 3580, "stars": [], "topic_id": 13418, "date_created": 1300328304.599333, "message": "@alex.. thanks! didn't turn that up in my searching. but doesn't take a comparison key or function.. so presumably works w/ __cmp__() ? my sort criteria isn't necessarily one I'd want to marry to my models forever. Is there some clever way to use this and provide a specific sort criteria?", "group_id": 81, "id": 370925}, {"user_id": 7, "stars": [{"date_created": 1300466620.9385359, "user_id": 1296}], "topic_id": 13418, "date_created": 1300332571.138617, "message": "It probably works with standard comparisons, if you want something else use the schwarzian transform", "group_id": 81, "id": 371270}] |