I have a json with players and teams. They are completly random like:
Now, i want to sort them based on their "team". I've read the docs and I'm completely confused and don't understand much.
{'puuid': '6bec3c19-6150-57e8-ba84-16220ab49198', 'name': 'Navis', 'tag': 'Games', 'team': 'Red', 'level': 110, 'character': 'Chamber', 'currenttier': 12, 'currenttier_patched': 'Gold 1', 'player_card': '1b6c643b-4f7e-aed8-88f6-f3932e682c14', 'player_title': 'a030f8ac-4475-d8d0-53a1-b8aafd5a3546', 'party_id': '578c7ad5-0eb1-4e6e-ab99-ecf971902cab', 'session_playtime': {'minutes': 231, 'seconds': 13860, 'milliseconds': 13860000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19043.1.256.64bit'}}, 'ability_casts': {'c_cast': 14, 'q_cast': 3, 'e_cast': 1, 'x_cast': 2}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/1b6c643b-4f7e-aed8-88f6-f3932e682c14/smallart.png', 'large': 'https://media.valorant-api.com/playercards/1b6c643b-4f7e-aed8-88f6-f3932e682c14/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/1b6c643b-4f7e-aed8-88f6-f3932e682c14/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/killfeedportrait.png'}}, 'stats': {'score': 1895, 'kills': 7, 'deaths': 15, 'assists': 2, 'bodyshots': 33, 'headshots': 1, 'legshots': 1}, 'economy': {'spent': {'overall': 43150, 'average': 2697}, 'loadout_value': {'overall': 52850, 'average': 3303}}, 'damage_made': 1114, 'damage_received': 2507}
{'puuid': '1446ff0a-9c8a-5cc6-af55-81bf6612a99b', 'name': 'Taha', 'tag': 'Yoru', 'team': 'Red', 'level': 95, 'character': 'Neon', 'currenttier': 13, 'currenttier_patched': 'Gold 2', 'player_card': '5b025468-4810-96e1-d19d-2ea35074586c', 'player_title': 'd13e579c-435e-44d4-cec2-6eae5a3c5ed4', 'party_id': '9d856301-1397-4e6a-b580-cff409a67ab1', 'session_playtime': {'minutes': 154, 'seconds': 9240, 'milliseconds': 9240000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.22000.1.256.64bit'}}, 'ability_casts': {'c_cast': 3, 'q_cast': 0, 'e_cast': 15, 'x_cast': 0}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/5b025468-4810-96e1-d19d-2ea35074586c/smallart.png', 'large': 'https://media.valorant-api.com/playercards/5b025468-4810-96e1-d19d-2ea35074586c/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/5b025468-4810-96e1-d19d-2ea35074586c/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/bb2a4828-46eb-8cd1-e765-15848195d751/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/bb2a4828-46eb-8cd1-e765-15848195d751/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/bb2a4828-46eb-8cd1-e765-15848195d751/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/bb2a4828-46eb-8cd1-e765-15848195d751/killfeedportrait.png'}}, 'stats': {'score': 1132, 'kills': 4, 'deaths': 16, 'assists': 1, 'bodyshots': 15, 'headshots': 5, 'legshots': 0}, 'economy': {'spent': {'overall': 40200, 'average': 2513}, 'loadout_value': {'overall': 45900, 'average': 2869}}, 'damage_made': 542, 'damage_received': 2326}
{'puuid': 'be2b3d3a-7281-5fb8-9b9a-61475111a8b0', 'name': 'YourLocalSkye', 'tag': 'M1lf', 'team': 'Blue', 'level': 99, 'character': 'Chamber', 'currenttier': 15, 'currenttier_patched': 'Platinum 1', 'player_card': '22a21e81-4b57-061f-d56f-aea3c4a8bf33', 'player_title': '631f4283-48b1-1855-d646-5e8f80e29821', 'party_id': 'c0ca03d6-dbf4-495a-9444-a50da9b2b5b3', 'session_playtime': {'minutes': 12, 'seconds': 720, 'milliseconds': 720000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.256.64bit'}}, 'ability_casts': {'c_cast': 14, 'q_cast': 5, 'e_cast': 38, 'x_cast': 1}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/22a21e81-4b57-061f-d56f-aea3c4a8bf33/smallart.png', 'large': 'https://media.valorant-api.com/playercards/22a21e81-4b57-061f-d56f-aea3c4a8bf33/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/22a21e81-4b57-061f-d56f-aea3c4a8bf33/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/22697a3d-45bf-8dd7-4fec-84a9e28c69d7/killfeedportrait.png'}}, 'stats': {'score': 4402, 'kills': 18, 'deaths': 10, 'assists': 3, 'bodyshots': 23, 'headshots': 11, 'legshots': 1}, 'economy': {'spent': {'overall': 35200, 'average': 2200}, 'loadout_value': {'overall': 55100, 'average': 3444}}, 'damage_made': 2724, 'damage_received': 1904}
{'puuid': 'c3a09504-4c30-520a-b1c6-00b95a35a127', 'name': 'FAST TECH YT', 'tag': '11111', 'team': 'Red', 'level': 159, 'character': 'KAY/O', 'currenttier': 14, 'currenttier_patched': 'Gold 3', 'player_card': 'f67a7c8f-4d3f-b76f-2921-478a4da44109', 'player_title': 'a030f8ac-4475-d8d0-53a1-b8aafd5a3546', 'party_id': '563d54bf-b56e-4c17-a771-cb69c02ab164', 'session_playtime': {'minutes': 2, 'seconds': 120, 'milliseconds': 120000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19042.1.256.64bit'}}, 'ability_casts': {'c_cast': 3, 'q_cast': 7, 'e_cast': 21, 'x_cast': 2}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/f67a7c8f-4d3f-b76f-2921-478a4da44109/smallart.png', 'large': 'https://media.valorant-api.com/playercards/f67a7c8f-4d3f-b76f-2921-478a4da44109/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/f67a7c8f-4d3f-b76f-2921-478a4da44109/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/601dbbe7-43ce-be57-2a40-4abd24953621/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/601dbbe7-43ce-be57-2a40-4abd24953621/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/601dbbe7-43ce-be57-2a40-4abd24953621/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/601dbbe7-43ce-be57-2a40-4abd24953621/killfeedportrait.png'}}, 'stats': {'score': 4180, 'kills': 14, 'deaths': 15, 'assists': 4, 'bodyshots': 41, 'headshots': 11, 'legshots': 1}, 'economy': {'spent': {'overall': 39200, 'average': 2450}, 'loadout_value': {'overall': 45850, 'average': 2866}}, 'damage_made': 2838, 'damage_received': 2466}
{'puuid': 'fd976800-eaa4-50ab-8d77-f2ba11ee2334', 'name': 'twitch otisvn', 'tag': 'EUW', 'team': 'Blue', 'level': 87, 'character': 'Viper', 'currenttier': 12, 'currenttier_patched': 'Gold 1', 'player_card': 'eac64718-4956-31ef-2c95-8b85e93d7fcc', 'player_title': 'd13e579c-435e-44d4-cec2-6eae5a3c5ed4', 'party_id': '9fff883f-0eb4-4c67-8621-f2f4fbf7d4cc', 'session_playtime': {'minutes': 4, 'seconds': 240, 'milliseconds': 240000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.768.64bit'}}, 'ability_casts': {'c_cast': 4, 'q_cast': 3, 'e_cast': 15, 'x_cast': 2}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/eac64718-4956-31ef-2c95-8b85e93d7fcc/smallart.png', 'large': 'https://media.valorant-api.com/playercards/eac64718-4956-31ef-2c95-8b85e93d7fcc/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/eac64718-4956-31ef-2c95-8b85e93d7fcc/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/707eab51-4836-f488-046a-cda6bf494859/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/707eab51-4836-f488-046a-cda6bf494859/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/707eab51-4836-f488-046a-cda6bf494859/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/707eab51-4836-f488-046a-cda6bf494859/killfeedportrait.png'}}, 'stats': {'score': 3051, 'kills': 14, 'deaths': 6, 'assists': 5, 'bodyshots': 31, 'headshots': 7, 'legshots': 5}, 'economy': {'spent': {'overall': 23700, 'average': 1481}, 'loadout_value': {'overall': 53300, 'average': 3331}}, 'damage_made': 1836, 'damage_received': 1093}
{'puuid': '4bc6d87f-7a7f-5fa2-a194-b3550e7768da', 'name': 'Sasha', 'tag': '4444', 'team': 'Blue', 'level': 72, 'character': 'Raze', 'currenttier': 14, 'currenttier_patched': 'Gold 3', 'player_card': '4dce4142-44bf-32e5-6f51-7e905389502c', 'player_title': '86bd997d-4e37-18c9-ada0-bf92e54baf60', 'party_id': '88353d38-c1bf-48a1-b943-ecced68711d4', 'session_playtime': {'minutes': 85, 'seconds': 5100, 'milliseconds': 5100000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.256.64bit'}}, 'ability_casts': {'c_cast': 12, 'q_cast': 7, 'e_cast': 8, 'x_cast': 1}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/4dce4142-44bf-32e5-6f51-7e905389502c/smallart.png', 'large': 'https://media.valorant-api.com/playercards/4dce4142-44bf-32e5-6f51-7e905389502c/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/4dce4142-44bf-32e5-6f51-7e905389502c/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/f94c3b30-42be-e959-889c-5aa313dba261/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/f94c3b30-42be-e959-889c-5aa313dba261/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/f94c3b30-42be-e959-889c-5aa313dba261/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/f94c3b30-42be-e959-889c-5aa313dba261/killfeedportrait.png'}}, 'stats': {'score': 5759, 'kills': 17, 'deaths': 11, 'assists': 9, 'bodyshots': 54, 'headshots': 10, 'legshots': 7}, 'economy': {'spent': {'overall': 50750, 'average': 3172}, 'loadout_value': {'overall': 67900, 'average': 4244}}, 'damage_made': 3512, 'damage_received': 2096}
{'puuid': 'd0a6c5fa-5094-5650-9b56-8154d3191725', 'name': 'EnzoNezo', 'tag': '3319', 'team': 'Blue', 'level': 101, 'character': 'Sage', 'currenttier': 12, 'currenttier_patched': 'Gold 1', 'player_card': '5b025468-4810-96e1-d19d-2ea35074586c', 'player_title': '5bdea980-4397-a1bd-1fab-659153ca196e', 'party_id': '33ca0f84-e3b0-4d28-8ae6-f6cda948db72', 'session_playtime': {'seconds': None, 'milliseconds': None}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.256.64bit'}}, 'ability_casts': {'c_cast': 8, 'q_cast': 9, 'e_cast': 4, 'x_cast': 1}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/5b025468-4810-96e1-d19d-2ea35074586c/smallart.png', 'large': 'https://media.valorant-api.com/playercards/5b025468-4810-96e1-d19d-2ea35074586c/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/5b025468-4810-96e1-d19d-2ea35074586c/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/569fdd95-4d10-43ab-ca70-79becc718b46/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/569fdd95-4d10-43ab-ca70-79becc718b46/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/569fdd95-4d10-43ab-ca70-79becc718b46/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/569fdd95-4d10-43ab-ca70-79becc718b46/killfeedportrait.png'}}, 'stats': {'score': 2738, 'kills': 8, 'deaths': 12, 'assists': 12, 'bodyshots': 39, 'headshots': 5, 'legshots': 19}, 'economy': {'spent': {'overall': 54150, 'average': 3384}, 'loadout_value': {'overall': 66200, 'average': 4138}}, 'damage_made': 1591, 'damage_received': 2199}
{'puuid': '70f7373a-ba78-5c9a-a963-767fbf27d9ad', 'name': 'Road2Radaint', 'tag': '6667', 'team': 'Red', 'level': 22, 'character': 'Jett', 'currenttier': 12, 'currenttier_patched': 'Gold 1', 'player_card': '9fb348bc-41a0-91ad-8a3e-818035c4e561', 'player_title': 'dd66cdcb-46cb-5e6e-f66f-51aa8cc3c14b', 'party_id': '578c7ad5-0eb1-4e6e-ab99-ecf971902cab', 'session_playtime': {'minutes': 2, 'seconds': 120, 'milliseconds': 120000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.256.64bit'}}, 'ability_casts': {'c_cast': 6, 'q_cast': 2, 'e_cast': 16, 'x_cast': 2}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/9fb348bc-41a0-91ad-8a3e-818035c4e561/smallart.png', 'large': 'https://media.valorant-api.com/playercards/9fb348bc-41a0-91ad-8a3e-818035c4e561/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/9fb348bc-41a0-91ad-8a3e-818035c4e561/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/add6443a-41bd-e414-f6ad-e58d267f4e95/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/add6443a-41bd-e414-f6ad-e58d267f4e95/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/add6443a-41bd-e414-f6ad-e58d267f4e95/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/add6443a-41bd-e414-f6ad-e58d267f4e95/killfeedportrait.png'}}, 'stats': {'score': 4271, 'kills': 12, 'deaths': 15, 'assists': 6, 'bodyshots': 32, 'headshots': 11, 'legshots': 3}, 'economy': {'spent': {'overall': 35100, 'average': 2194}, 'loadout_value': {'overall': 50900, 'average': 3181}}, 'damage_made': 2682, 'damage_received': 2678}
{'puuid': '1ccd31a8-6109-5edd-bd58-bb90f3b55a1d', 'name': 'E S Q U I', 'tag': '1234', 'team': 'Red', 'level': 61, 'character': 'Fade', 'currenttier': 12, 'currenttier_patched': 'Gold 1', 'player_card': '39729022-445a-d7bb-52e7-9e909e481db2', 'player_title': '025b0aaf-4bc6-522c-faae-a484779c5d03', 'party_id': '51217228-3efc-42f5-9aac-9ef20835a09b', 'session_playtime': {'minutes': 83, 'seconds': 4980, 'milliseconds': 4980000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.256.64bit'}}, 'ability_casts': {'c_cast': 10, 'q_cast': 6, 'e_cast': 14, 'x_cast': 2}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/39729022-445a-d7bb-52e7-9e909e481db2/smallart.png', 'large': 'https://media.valorant-api.com/playercards/39729022-445a-d7bb-52e7-9e909e481db2/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/39729022-445a-d7bb-52e7-9e909e481db2/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/dade69b4-4f5a-8528-247b-219e5a1facd6/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/dade69b4-4f5a-8528-247b-219e5a1facd6/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/dade69b4-4f5a-8528-247b-219e5a1facd6/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/dade69b4-4f5a-8528-247b-219e5a1facd6/killfeedportrait.png'}}, 'stats': {'score': 2287, 'kills': 8, 'deaths': 15, 'assists': 0, 'bodyshots': 17, 'headshots': 4, 'legshots': 2}, 'economy': {'spent': {'overall': 43000, 'average': 2688}, 'loadout_value': {'overall': 47750, 'average': 2984}}, 'damage_made': 1382, 'damage_received': 2424}
{'puuid': '55ac8119-1247-517d-85fb-5134a957d8df', 'name': 'Menzirs', 'tag': '9042', 'team': 'Blue', 'level': 81, 'character': 'Skye', 'currenttier': 14, 'currenttier_patched': 'Gold 3', 'player_card': '4ca63988-4ca6-2911-a1b5-98a4b765dffd', 'player_title': '39374ca0-447b-1d4e-aa38-e6b0e0b07946', 'party_id': '5c59434c-7a64-4736-956c-e35038aaabeb', 'session_playtime': {'minutes': 183, 'seconds': 10980, 'milliseconds': 10980000}, 'behavior': {'afk_rounds': 0, 'friendly_fire': {'incoming': 0, 'outgoing': 0}, 'rounds_in_spawn': 0}, 'platform': {'type': 'PC', 'os': {'name': 'Windows', 'version': '10.0.19044.1.768.64bit'}}, 'ability_casts': {'c_cast': 4, 'q_cast': 5, 'e_cast': 26, 'x_cast': 3}, 'assets': {'card': {'small': 'https://media.valorant-api.com/playercards/4ca63988-4ca6-2911-a1b5-98a4b765dffd/smallart.png', 'large': 'https://media.valorant-api.com/playercards/4ca63988-4ca6-2911-a1b5-98a4b765dffd/largeart.png', 'wide': 'https://media.valorant-api.com/playercards/4ca63988-4ca6-2911-a1b5-98a4b765dffd/wideart.png'}, 'agent': {'small': 'https://media.valorant-api.com/agents/6f2a04ca-43e0-be17-7f36-b3908627744d/displayicon.png', 'bust': 'https://media.valorant-api.com/agents/6f2a04ca-43e0-be17-7f36-b3908627744d/bustportrait.png', 'full': 'https://media.valorant-api.com/agents/6f2a04ca-43e0-be17-7f36-b3908627744d/fullportrait.png', 'killfeed': 'https://media.valorant-api.com/agents/6f2a04ca-43e0-be17-7f36-b3908627744d/killfeedportrait.png'}}, 'stats': {'score': 4217, 'kills': 19, 'deaths': 6, 'assists': 7, 'bodyshots': 35, 'headshots': 12, 'legshots': 0}, 'economy': {'spent': {'overall': 32700, 'average': 2044}, 'loadout_value': {'overall': 67900, 'average': 4244}}, 'damage_made': 2573, 'damage_received': 1422}
This is only a part of the JSON which is neccessary to my Question. The other part of the JSON is way longer.
CodePudding user response:
Use the sorted
function, with the key as the 'team'
value.
data = json.load(open('filepath.json'))
result = sorted(data, key=lambda x: x['team'])