所以我完全被困住了。我有一些字典需要按“ StartingSequenceNumber”进行排序。在执行此操作之前,尽管我需要修改列表,以便将父级的子级嵌套在其父级下方。
这是对象:
[{'SequenceNumberRange': {'EndingSequenceNumber': '2633238500000000007210427396',
'StartingSequenceNumber': '2633238500000000007210194409'},
'ShardId': 'shardId-00000001560257151382-0511248f'},
{'SequenceNumberRange': {'EndingSequenceNumber': '2633238500000000007213849718',
'StartingSequenceNumber': '2633238500000000007213849718'},
'ShardId': 'shardId-00000001560257151491-87e08366'},
{'SequenceNumberRange': {'EndingSequenceNumber': '2633251700000000001798778226',
'StartingSequenceNumber': '2633248700000000001797056631'},
'ShardId': 'shardId-00000001560257151593-e403a304'},
{'SequenceNumberRange': {'EndingSequenceNumber': '2633234300000000025942601968',
'StartingSequenceNumber': '2633234300000000025942601968'},
'ShardId': 'shardId-00000001560257151699-5b26f959'},
{'ParentShardId': 'shardId-00000001560257151593-e403a304',
'SequenceNumberRange': {'EndingSequenceNumber': '2634037900000000000108985046',
'StartingSequenceNumber': '2634034900000000000105825431'},
'ShardId': 'shardId-00000001560271360529-805b9f3a'},
{'ParentShardId': 'shardId-00000001560257151491-87e08366',
'SequenceNumberRange': {'EndingSequenceNumber': '2634025200000000040876171219',
'StartingSequenceNumber': '2634025200000000040876171219'},
'ShardId': 'shardId-00000001560271429234-b8057033'},
{'ParentShardId': 'shardId-00000001560257151699-5b26f959',
'SequenceNumberRange': {'EndingSequenceNumber': '2634029900000000003093016867',
'StartingSequenceNumber': '2634029800000000003091145714'},
'ShardId': 'shardId-00000001560271584901-5bc73caa'},
{'ParentShardId': 'shardId-00000001560257151382-0511248f',
'SequenceNumberRange': {'EndingSequenceNumber': '2634044600000000000092715064',
'StartingSequenceNumber': '2634044600000000000092715064'},
'ShardId': 'shardId-00000001560271787021-e3ac5a4d'},
{'ParentShardId': 'shardId-00000001560271584901-5bc73caa',
'SequenceNumberRange': {'EndingSequenceNumber': '2634730900000000002873233326',
'StartingSequenceNumber': '2634730900000000002873233326'},
'ShardId': 'shardId-00000001560284300833-b247355c'},
{'ParentShardId': 'shardId-00000001560271787021-e3ac5a4d',
'SequenceNumberRange': {'EndingSequenceNumber': '2634858000000000080977292775',
'StartingSequenceNumber': '2634858000000000080977292775'},
'ShardId': 'shardId-00000001560286548924-f33e4310'},
{'ParentShardId': 'shardId-00000001560271360529-805b9f3a',
'SequenceNumberRange': {'EndingSequenceNumber': '2634898600000000025129406835',
'StartingSequenceNumber': '2634898600000000025129406835'},
'ShardId': 'shardId-00000001560286959816-2865162a'},
{'ParentShardId': 'shardId-00000001560271429234-b8057033',
'SequenceNumberRange': {'EndingSequenceNumber': '2634901400000000006787250705',
'StartingSequenceNumber': '2634901400000000006787250705'},
'ShardId': 'shardId-00000001560287331121-d2d13f68'},
{'ParentShardId': 'shardId-00000001560284300833-b247355c',
'SequenceNumberRange': {'EndingSequenceNumber': '2635547600000000004917974579',
'StartingSequenceNumber': '2635547600000000004917974579'},
'ShardId': 'shardId-00000001560299126708-cd58deb8'},
{'ParentShardId': 'shardId-00000001560286959816-2865162a',
'SequenceNumberRange': {'EndingSequenceNumber': '2635614400000000011112961891',
'StartingSequenceNumber': '2635614400000000011112961891'},
'ShardId': 'shardId-00000001560299943423-5092e710'},
{'ParentShardId': 'shardId-00000001560286548924-f33e4310',
'SequenceNumberRange': {'EndingSequenceNumber': '2635629600000000035186152685',
'StartingSequenceNumber': '2635629600000000035186152685'},
'ShardId': 'shardId-00000001560300547953-8cf11cdb'},
{'ParentShardId': 'shardId-00000001560287331121-d2d13f68',
'SequenceNumberRange': {'EndingSequenceNumber': '2635707900000000000023976055',
'StartingSequenceNumber': '2635707900000000000023976055'},
'ShardId': 'shardId-00000001560301980437-f2f9475d'},
{'ParentShardId': 'shardId-00000001560299126708-cd58deb8',
'SequenceNumberRange': {'EndingSequenceNumber': '2636370100000000074206229014',
'StartingSequenceNumber': '2636370100000000074206229014'},
'ShardId': 'shardId-00000001560314058242-5339522d'},
{'ParentShardId': 'shardId-00000001560299943423-5092e710',
'SequenceNumberRange': {'EndingSequenceNumber': '2636417200000000001926939028',
'StartingSequenceNumber': '2636417200000000001926939028'},
'ShardId': 'shardId-00000001560314505275-5c841625'},
{'ParentShardId': 'shardId-00000001560301980437-f2f9475d',
'SequenceNumberRange': {'EndingSequenceNumber': '2636428500000000041510315707',
'StartingSequenceNumber': '2636428500000000041510315707'},
'ShardId': 'shardId-00000001560315054099-344f5f91'},
{'ParentShardId': 'shardId-00000001560300547953-8cf11cdb',
'SequenceNumberRange': {'EndingSequenceNumber': '2636441300000000002965649614',
'StartingSequenceNumber': '2636441300000000002965649614'},
'ShardId': 'shardId-00000001560315261944-f960b4d5'},
{'ParentShardId': 'shardId-00000001560314058242-5339522d',
'SequenceNumberRange': {'EndingSequenceNumber': '2637138500000000006731034556',
'StartingSequenceNumber': '2637138500000000006731034556'},
'ShardId': 'shardId-00000001560327995519-569c81d3'},
{'ParentShardId': 'shardId-00000001560314505275-5c841625',
'SequenceNumberRange': {'EndingSequenceNumber': '2637221000000000060883856558',
'StartingSequenceNumber': '2637220800000000060875264197'},
'ShardId': 'shardId-00000001560329076755-04a49b76'},
{'ParentShardId': 'shardId-00000001560315054099-344f5f91',
'SequenceNumberRange': {'EndingSequenceNumber': '2637254600000000004923595364',
'StartingSequenceNumber': '2637254600000000004923595364'},
'ShardId': 'shardId-00000001560330042571-05db45b1'},
{'ParentShardId': 'shardId-00000001560315261944-f960b4d5',
'SequenceNumberRange': {'EndingSequenceNumber': '2637257900000000011211752197',
'StartingSequenceNumber': '2637257900000000011211752197'},
'ShardId': 'shardId-00000001560330079021-de30e4d9'},
{'ParentShardId': 'shardId-00000001560329076755-04a49b76',
'SequenceNumberRange': {'StartingSequenceNumber': '2637983400000000003447451684'},
'ShardId': 'shardId-00000001560342912772-46b7356b'},
{'ParentShardId': 'shardId-00000001560330042571-05db45b1',
'SequenceNumberRange': {'StartingSequenceNumber': '2637969900000000035651597823'},
'ShardId': 'shardId-00000001560343013811-47406cbf'},
{'ParentShardId': 'shardId-00000001560330079021-de30e4d9',
'SequenceNumberRange': {'StartingSequenceNumber': '2637977700000000003612170759'},
'ShardId': 'shardId-00000001560343144798-ba082171'},
{'ParentShardId': 'shardId-00000001560327995519-569c81d3',
'SequenceNumberRange': {'StartingSequenceNumber': '2638017900000000003390456540'},
'ShardId': 'shardId-00000001560343972355-674be75d'}]
我真正想要的条目是:
{'ParentShardId': 'shardId-00000001560330042571-05db45b1',
'SequenceNumberRange': {'StartingSequenceNumber': '2637969900000000035651597823'},
'ShardId': 'shardId-00000001560343013811-47406cbf'}
上面的条目是以下条目的最新子级:
{'SequenceNumberRange': {'EndingSequenceNumber': '2633238500000000007213849718',
'StartingSequenceNumber': '2633238500000000007213849718'},
'ShardId': 'shardId-00000001560257151491-87e08366'}
该条目丢失了孩子。
所以我需要将所有孩子嵌套在父母的下面,然后对列表和孩子列表进行排序。
这有意义吗? ...我未包含任何代码,因为我不知道该如何处理。任何帮助表示赞赏!