{"componentChunkName":"component---src-templates-material-js","path":"/workshops/2021/01/13/vvedenie-v-python-chast-9-sortirovka/","result":{"pageContext":{"pageParameters":{"isPreview":false,"isMirror":false,"delay_to_show_donate_popup_seconds":7,"about_page":false,"games_page":true,"games_page_link_in_header":false,"donate_popup_show_ru":true,"donate_popup_title_ru":"Без вас — нас не будет","donate_popup_content_ru":"Помогите нам добывать и рассказывать важные истории. Участие каждого — важно!","donate_popup_show_en":true,"donate_popup_title_en":"We can’t do it alone!","donate_popup_content_en":"Help us uncover and share the stories that matter. Every contribution makes a difference","display_regular_donors_banner":false,"showPatreonMethod":true,"useNewMaterialDonationBanner":true,"new_donations_page_design":true,"donations_popup_variants":{"ru":[{"id":"kc19b","title":"Сохраните журналистику для людей в России ","subtitle":"Читают нас прежде всего люди в России, но будущее «Важных историй» зависит от тех, кто живет за пределами страны. Поддержите нас ежемесячным донатом — сохраните независимую журналистику для ваших близких, которые остаются в России.","is_active":true,"background":"linear-gradient(10deg, #421f20 5%, #994146)"},{"id":"33tc9","title":"У пропаганды есть миллиарды из бюджета. У нас — только вы","subtitle":"Перемены возможны, если независимые от власти журналисты продолжают свою работу день за днем, год за годом. Мы рассказываем важные истории уже шесть лет. Помогите нам продолжать.","is_active":true,"background":"linear-gradient(10deg, #421f20 5%, #994146)"}],"en":[{"id":"nj1py","title":"Important stories don’t tell themselves","subtitle":"Independent journalism comes at a cost. We answer to no owners or advertisers — only to you, our readers.  Your ongoing support allows us to keep exposing the truth. Without you, we won’t be here.","is_active":true,"background":"linear-gradient(10deg, #421f20 5%, #994146)"},{"id":"xdfc1","title":"Help us outlast the Kremlin censorship","subtitle":"Censorship lose to journalism that keeps showing up, year after year. Monthly donors are what make that possible","is_active":true,"background":"linear-gradient(10deg, #421f20 5%, #994146)"},{"id":"ck121","title":"State propaganda has billions to spend. We have only you to rely on","subtitle":"Change happens when independent journalists keep showing up — day after day, year after year. Six years in, we're still showing up. Help us keep going with a monthly donation.","is_active":true,"background":"linear-gradient(10deg, #421f20 5%, #994146)"}]},"feedback_page":true,"donorsCount":0,"showAuthorsRequestAfterMaterial":true,"radioPage":true,"radioExists":{"ru":true,"en":false},"singlePlaylistPath":{"ru":"/radio/2025/12/22/razgovori-ovazhnikh/"},"with_bookmarks":true,"news_feed":true,"news_feed_skeleton":false,"news_page_redesign":true,"with_topics":true,"materials_topics":false,"topics_page":true,"with_pdf_share":false,"with_native_share":false,"preferred_source_page":true,"charon_new_form":true,"preferred_source_promos":true,"charon_en_page":true},"pk":188,"header":"Введение в Python. Часть 9. Сортировка","lead":"Как сортировать данные в Python","category":"workshops","entry_image":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-1920x960px_1x.webp","url_2x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-1920x960px_2x.webp","for_width":1920,"for_height":960,"real_width_1x":1920,"real_width_2x":3840,"real_height_1x":960,"real_height_2x":1920},{"format":"jpg","url_1x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-1920x960px_1x.jpg","url_2x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-1920x960px_2x.jpg","for_width":1920,"for_height":960,"real_width_1x":1920,"real_width_2x":3840,"real_height_1x":960,"real_height_2x":1920},{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-1272x636px_1x.webp","url_2x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-1272x636px_2x.webp","for_width":1272,"for_height":636,"real_width_1x":1272,"real_width_2x":2544,"real_height_1x":636,"real_height_2x":1272},{"format":"jpg","url_1x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-1272x636px_1x.jpg","url_2x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-1272x636px_2x.jpg","for_width":1272,"for_height":636,"real_width_1x":1272,"real_width_2x":2544,"real_height_1x":636,"real_height_2x":1272},{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-912x456px_1x.webp","url_2x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-912x456px_2x.webp","for_width":912,"for_height":456,"real_width_1x":912,"real_width_2x":1824,"real_height_1x":456,"real_height_2x":912},{"format":"jpg","url_1x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-912x456px_1x.jpg","url_2x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-912x456px_2x.jpg","for_width":912,"for_height":456,"real_width_1x":912,"real_width_2x":1824,"real_height_1x":456,"real_height_2x":912},{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-600x400px_1x.webp","url_2x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-600x400px_2x.webp","for_width":600,"for_height":400,"real_width_1x":600,"real_width_2x":1200,"real_height_1x":400,"real_height_2x":800},{"format":"jpg","url_1x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-600x400px_1x.jpg","url_2x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-600x400px_2x.jpg","for_width":600,"for_height":400,"real_width_1x":600,"real_width_2x":1200,"real_height_1x":400,"real_height_2x":800},{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-360x360px_1x.webp","url_2x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-360x360px_2x.webp","for_width":360,"for_height":360,"real_width_1x":360,"real_width_2x":720,"real_height_1x":360,"real_height_2x":720},{"format":"jpg","url_1x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-360x360px_1x.jpg","url_2x":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-360x360px_2x.jpg","for_width":360,"for_height":360,"real_width_1x":360,"real_width_2x":720,"real_height_1x":360,"real_height_2x":720}],"entry_image_credit":"","blocks":[{"data":"Данные часто собираются и хранятся в беспорядке, но чтобы проанализировать их, как правило, нужно их сперва отсортировать – по возрастанию или убыванию.&nbsp;В этом выпуске – о том, как устроена сортировка в Python.","type":"p","className":""},{"data":{"data":{"url":"https://www.youtube.com/embed/3d7XntQVG_g","text":"Видео: Глеб Лиманский","provider":"youtube","rawInput":"https://www.youtube.com/watch?v=3d7XntQVG_g&ab_channel=%D0%9C%D0%B0%D1%81%D1%82%D0%B5%D1%80%D1%81%D0%BA%D0%B0%D1%8F%D0%92%D0%B0%D0%B6%D0%BD%D1%8B%D1%85%D0%B8%D1%81%D1%82%D0%BE%D1%80%D0%B8%D0%B9","ratio_mobile":"16:9","ratio_desktop":"16:9"},"category":"video-embed"},"type":"video-embed"},{"data":"Алгоритм Bubble Sort","type":"h2","className":""},{"data":"Есть несколько алгоритмов сортировки, рассмотрим самый простой. Bubble sort или пузырьковая сортировка получила такое название, потому что с ее помощью мы постепенно перемещаем элементы таким образом, что наименьший оказывается в самом начале, так же как пузырек воздуха всплывает в воде наверх. А самый большой элемент, наоборот, опускается вниз – то есть в конец массива.","type":"p","className":""},{"data":{"data":{"text":"Ваше пожертвование поможет нам готовить еще больше выпусков Мастерской\n","title":"Нравятся наши лекции? Поддержите нас","buttonText":"Поддержать «Важные истории»"},"category":"donate-embed"},"type":"donate-embed"},{"data":"Этот метод по очереди сравнивает каждые два соседних элемента и переставляет их местами, если порядок неправильный. Например, возьмем следующий ряд чисел: 67381. Сначала алгоритм сравнит первые два соседних числа: 6 меньше 7, значит порядок правильный, они остаются на своих местах. Затем следующие два числа –&nbsp;7 больше 3, значит они меняются местами. Затем он сравнит 7 и 8, и тоже переставит их местами и так далее. После первого прохода по ряду чисел в конце окажется самое большое число – 8. И дальше алгоритм проходит по всем числам снова и будет проходить столько раз, пока каждое число не встанет на свое место – от меньшего к большему. ","type":"p","className":""},{"data":"Вот как это выглядит на языке Питон. Есть список с числами в рандомном порядке, который нужно отсортировать. Сперва сравним первые два числа и поменяем их местами, если порядок неправильный – то есть второе число больше первого. И попросим распечатать получившийся список.","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/4cd30e45591144d4b890732f1c45cffc-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/4cd30e45591144d4b890732f1c45cffc-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":158,"real_height_2x":317},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/4cd30e45591144d4b890732f1c45cffc-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/4cd30e45591144d4b890732f1c45cffc-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":158,"real_height_2x":317}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"Этот код сравнил 6 с 7, и оставил их на своих местах.&nbsp;Теперь сравним следующие два числа: меняем в коде индексы на 1 и 2. И видим, что он сравнил 3 и 7 и поменял их местами.","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/7a48b80b18c04efc8cb4811cd35e9140-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/7a48b80b18c04efc8cb4811cd35e9140-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":119,"real_height_2x":238},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/7a48b80b18c04efc8cb4811cd35e9140-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/7a48b80b18c04efc8cb4811cd35e9140-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":119,"real_height_2x":238}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"Эту операцию нам надо выполнять столько раз, сколько у нас в списке чисел, чтобы каждое из них нашло свое место.&nbsp;Поэтому чтобы не прописывать для каждой пары одну и ту же операцию, мы создаем цикл, равный длине нашего массива минус 1, потому что последнее число в списке не имеет соседа справа, и значит эту операцию сравнения производить не нужно.&nbsp;И просим распечатать получившийся список внутри цикла, чтобы видеть каждый шаг кода.","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/f4cf1eaf3a96492cb97b1638ee1fb900-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/f4cf1eaf3a96492cb97b1638ee1fb900-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":326,"real_height_2x":651},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/f4cf1eaf3a96492cb97b1638ee1fb900-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/f4cf1eaf3a96492cb97b1638ee1fb900-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":326,"real_height_2x":651}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"Этот код постепенно переместил 8 в конец, после одного обхода одно число нашло свое правильное место. Но на этом сортировка не заканчивается. Нам нужно, чтобы каждый элемент массива переместился на свое место – значит нужно сделать столько обходов, сколько у нас чисел. Поэтому мы создаем новый цикл с количеством итераций, равным длине списка. Но здесь мы увидим, что на последнем обходе ничего не поменяется, потому что когда 3 нашла свое место, самый минимальный элемент 1 тоже встал на свое место, значит мы можем отнять 1, чтобы не делать последний обход. Как еще можно оптимизировать этот код? После каждого обхода в конце списка оказывается наибольшее число, и сравнение тех чисел, которые уже нашли свое место, производить не надо. Поэтому мы можем отнять внутри цикла количество обходов, соответствующее итерации цикла – run. Тогда код не будет выполнять лишних операций сравнения.","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/6de00190780046dea3f90808617453ee-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/6de00190780046dea3f90808617453ee-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":436,"real_height_2x":874},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/6de00190780046dea3f90808617453ee-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/6de00190780046dea3f90808617453ee-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":436,"real_height_2x":874}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"Давайте теперь превратим наш алгоритм в функцию, которой можно будет передавать любые другие массивы. И протестируем ее на новом списке.","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/4bed836ce43b484eafc719b4505a9ced-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/4bed836ce43b484eafc719b4505a9ced-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":252,"real_height_2x":503},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/4bed836ce43b484eafc719b4505a9ced-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/4bed836ce43b484eafc719b4505a9ced-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":252,"real_height_2x":503}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"Встроенные методы и функции сортировки","type":"h2","className":""},{"data":"В Python есть встроенные функции и методы сортировки, которые позволяют проделать те же операции одной строчкой кода. В большинстве случаев программисты обходятся ими, но алгоритмы, пример которого мы только что протестировали, важно освоить, чтобы понимать механизм работы этих встроенных функций и методов. И в отдельных случаях, когда данных так много, что встроенные функции и методы сортируют их слишком долго, суметь написать более быструю программу.","type":"p","className":""},{"data":"Метод <strong>.sort()</strong> сортирует список и сохраняет его в отсортированном виде. А функция <strong>sorted()</strong> создает новый отсортированный список без изменения исходного. ","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/9db2007ad1e34ef08c8468e317c08c57-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/9db2007ad1e34ef08c8468e317c08c57-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":292,"real_height_2x":584},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/9db2007ad1e34ef08c8468e317c08c57-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/9db2007ad1e34ef08c8468e317c08c57-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":292,"real_height_2x":584}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"Еще одно их отличие в том, что функция sorted работает не только со списками, но и другими объектами. Например, вот что получится, если мы отсортируем строку. ","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/89af46b0b65643a48f7176f2230c9159-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/89af46b0b65643a48f7176f2230c9159-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":93,"real_height_2x":186},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/89af46b0b65643a48f7176f2230c9159-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/89af46b0b65643a48f7176f2230c9159-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":93,"real_height_2x":186}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"Эта функция возвращает список каждый раз, несмотря на то, какой тип данных был ей передан. В случае со словарями, она возвращает отсортированный список словарных ключей.","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/45bb02560f7e47e3834384cb51639f6b-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/45bb02560f7e47e3834384cb51639f6b-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":98,"real_height_2x":197},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/45bb02560f7e47e3834384cb51639f6b-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/45bb02560f7e47e3834384cb51639f6b-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":98,"real_height_2x":197}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"По умолчанию сортировка будет происходить по возрастанию, но мы можем передавать функции и методу параметры. За это отвечает параметр <strong>reverse</strong>. Если мы передадим ему параметр <strong>True</strong>, сортировка будет происходить по убыванию.","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/3db51e7cc7ce4f9d91eec7ab8bcfb796-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/3db51e7cc7ce4f9d91eec7ab8bcfb796-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":103,"real_height_2x":206},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/3db51e7cc7ce4f9d91eec7ab8bcfb796-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/3db51e7cc7ce4f9d91eec7ab8bcfb796-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":103,"real_height_2x":206}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"Кроме этого, у sort и sorted есть параметр <strong>key</strong>, который указывает на функцию сравнения. Например, если мы хотим отсортировать значения без учета регистра текста, можно  сделать так:","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/9034238e1f1b4a929cf27f92cb1be8e3-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/9034238e1f1b4a929cf27f92cb1be8e3-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":86,"real_height_2x":174},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/9034238e1f1b4a929cf27f92cb1be8e3-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/9034238e1f1b4a929cf27f92cb1be8e3-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":86,"real_height_2x":174}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"Внутри параметра key могут находиться не только встроенные функции, но и написанные нами. Они обычно нужны, когда мы хотим отсортировать сложный объект.&nbsp;Например, есть такая проблема: если попытаться отсортировать сложный объект (который состоит, например, из списка списков), сортировка будет выполняться по первому элементу. ","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/35da194a5e5b4a2cb95400c0c4e5a6ab-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/35da194a5e5b4a2cb95400c0c4e5a6ab-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":170,"real_height_2x":341},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/35da194a5e5b4a2cb95400c0c4e5a6ab-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/35da194a5e5b4a2cb95400c0c4e5a6ab-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":170,"real_height_2x":341}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"Если мы хотим, чтобы сортировка происходила не по первому элементу, мы можем сами создать специальную функцию.&nbsp;","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/30c3b420aa22457d9b23040e449bd7d0-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/30c3b420aa22457d9b23040e449bd7d0-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":304,"real_height_2x":609},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/30c3b420aa22457d9b23040e449bd7d0-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/30c3b420aa22457d9b23040e449bd7d0-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":304,"real_height_2x":609}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"С помощью функций мы можем производить сортировку и внутри словарей –&nbsp;например, отсортировать эти данные по доходу супруги чиновника из ФСБ.","type":"p","className":""},{"data":{"data":{"images":[{"credit":"","caption":"","imagesList":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/f03d683403f045cbb3eda4b5b9d61f28-1200xautopx_1x.webp","url_2x":"https://static.istories.media/uploaded/images/f03d683403f045cbb3eda4b5b9d61f28-1200xautopx_2x.webp","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":204,"real_height_2x":409},{"format":"png","url_1x":"https://static.istories.media/uploaded/images/f03d683403f045cbb3eda4b5b9d61f28-1200xautopx_1x.png","url_2x":"https://static.istories.media/uploaded/images/f03d683403f045cbb3eda4b5b9d61f28-1200xautopx_2x.png","for_width":1200,"for_height":"auto","real_width_1x":1200,"real_width_2x":2400,"real_height_1x":204,"real_height_2x":409}]}]},"category":"image-embed"},"type":"image-embed"},{"data":"Теперь вы умеете сортировать данные с помощью Python. Тетрадку этого урока можно <a href=\"https://github.com/iStoriesMedia/python_lessons/blob/main/%D0%A3%D1%80%D0%BE%D0%BA%209.%20%D0%A1%D0%BE%D1%80%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%BA%D0%B0.ipynb\" data-type=\"usual\" target=\"_blank\">скачать</a> на нашем GitHub.","type":"p","className":""}],"created_at_date":"2021-01-13","updated_at_date":null,"created_at_date_time":null,"updated_at_date_time":null,"is_exclusive":false,"is_urgent":false,"initially_published_at":"2021-01-13T06:53:27.260Z","has_additional_facts":false,"locale":"ru","has_visualization_without_fallback":false,"spec_project":null,"header_secondary":"","warning":"","is_translated_by_ai":false,"with_donation_banner":true,"donation_banner_header":"","donation_banner_text":"","media_outlet__codename":null,"with_authors_request_banner":false,"faq":[],"_path":"/workshops/2021/01/13/vvedenie-v-python-chast-9-sortirovka/","is_published":true,"authors_list":[{"id":13,"lead":"Если вы хотите рассказать мне свою историю, пишите на почту sonya.savina@istories.media.","_path":"sonya-savina","avatar":[{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-896x504px_1x.webp","url_2x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-896x504px_2x.webp","for_width":896,"for_height":504,"real_width_1x":896,"real_width_2x":1792,"real_height_1x":504,"real_height_2x":1008},{"format":"jpg","url_1x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-896x504px_1x.jpg","url_2x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-896x504px_2x.jpg","for_width":896,"for_height":504,"real_width_1x":896,"real_width_2x":1792,"real_height_1x":504,"real_height_2x":1008},{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-688x387px_1x.webp","url_2x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-688x387px_2x.webp","for_width":688,"for_height":387,"real_width_1x":688,"real_width_2x":1376,"real_height_1x":387,"real_height_2x":774},{"format":"jpg","url_1x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-688x387px_1x.jpg","url_2x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-688x387px_2x.jpg","for_width":688,"for_height":387,"real_width_1x":688,"real_width_2x":1376,"real_height_1x":387,"real_height_2x":774},{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-416x234px_1x.webp","url_2x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-416x234px_2x.webp","for_width":416,"for_height":234,"real_width_1x":416,"real_width_2x":832,"real_height_1x":234,"real_height_2x":468},{"format":"jpg","url_1x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-416x234px_1x.jpg","url_2x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-416x234px_2x.jpg","for_width":416,"for_height":234,"real_width_1x":416,"real_width_2x":832,"real_height_1x":234,"real_height_2x":468},{"format":"webp","url_1x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-336x189px_1x.webp","url_2x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-336x189px_2x.webp","for_width":336,"for_height":189,"real_width_1x":336,"real_width_2x":672,"real_height_1x":188,"real_height_2x":378},{"format":"jpg","url_1x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-336x189px_1x.jpg","url_2x":"https://static.istories.media/uploaded/images/a0e1983f65dd43929246814147e02504-336x189px_2x.jpg","for_width":336,"for_height":189,"real_width_1x":336,"real_width_2x":672,"real_height_1x":188,"real_height_2x":378}],"lead_en":"","ordering":null,"position":"Авторка","is_public":true,"last_name":"Савина","first_name":"Соня","position_en":"Author","last_name_en":"Savina","first_name_en":"Sonya"}],"external_authors_list":[],"editors_list":[],"external_editors_list":[],"participants_list":[],"external_participants_list":[],"partners_list":[],"case":null,"translated_material":null,"audio_material":null,"text_material":null,"id":188,"topics":[],"meta":{"og_title":"","og_description":"","twitter_title":"","twitter_description":"","og_image":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-1920x960px_1x.jpg","twitter_image":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-1920x960px_1x.jpg","vk_image":"https://static.istories.media/uploaded/images/4a2798b5746c47e6917e554ea8363ceb-1920x960px_1x.jpg"},"tags":["программирование","мастерская","python"],"playlist":null,"socialMediaBanners":[{"id":10,"text":"У пропаганды есть миллиарды из бюджета. У нас — только вы","link":"","codename":"donation"},{"id":14,"text":"Список погибших и пропавших без вести российских военных","link":"","codename":"haron"},{"id":18,"text":"","link":"","codename":"mobile_app"},{"id":6,"text":"Оставайтесь на связи: подпишитесь на нашу рассылку","link":"","codename":"newsletter"}]}},"staticQueryHashes":["764694655"],"slicesMap":{}}