{"id":326658,"date":"2021-07-19T15:00:18","date_gmt":"2021-07-19T15:00:18","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=326658"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=326658","title":{"rendered":"\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 NumPy (\u0438 \u0442\u0430\u043d\u0446\u044b, \u0438 \u043c\u0435\u043c\u044b)"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p><strong>\u0412\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u044f<\/strong>: <\/p>\n<p>\u0414\u0430, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043d\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u0431\u0438\u0442\u043e\u0439 \u0442\u0435\u043c\u044b, \u0447\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u0435\u043d\u044f \u0432 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0442\u0430\u043a \u0443\u0432\u043b\u0435\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u044b \u0432 NumPy, \u0447\u0442\u043e \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0432\u0441\u0435\u043c \u043e\u0431 \u044d\u0442\u043e\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u043b\u043a\u0430\u044f \u0432\u0435\u0449\u044c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0437\u0430\u043d\u0443\u0434\u0441\u0442\u0432\u043e \u043a\u0430\u043a\u043e\u0435-\u0442\u043e, \u043d\u043e \u0442\u0435\u0448\u0443 \u0441\u0435\u0431\u044f \u043d\u0430\u0434\u0435\u0436\u0434\u043e\u0439, \u0447\u0442\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0442\u0435\u043c\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b! \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u043b\u044e\u0434\u0435\u0439, \u043a\u0430\u043a \u044f, \u043f\u0435\u0440\u0435\u0448\u0435\u0434\u0448\u0438\u0445 \u0438\u0437 \u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u0441\u0444\u0435\u0440 (\u0438\u0437 \u0442\u0435\u043b\u0435\u043a\u043e\u043c\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440), \u0433\u0434\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u043d\u0435 \u0438\u0437\u0443\u0447\u0430\u0442\u044c\u0441\u044f (\u0431\u044b\u0432\u0430\u0435\u0442 \u0438 \u0442\u0430\u043a\u043e\u0435). \u0415\u0441\u043b\u0438 \u0433\u0434\u0435-\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0430\u043f\u0443\u0442\u0430\u043b (\u0438\u043b\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0434\u043b\u044f \u0432\u0430\u0441 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c), \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0438!<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b77\/266\/225\/b77266225dc4b795ffa4b40bb6c98d7f.jpeg\" alt=\" \" title=\" \" width=\"780\" height=\"780\"><figcaption> <\/figcaption><\/figure>\n<p>\u0418\u0442\u0430\u043a<em>, <\/em>\u044f \u0438\u0441\u043a\u0440\u0435\u043d\u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0442\u0435\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438&nbsp;<strong>\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438<\/strong>&nbsp;\u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438&nbsp;<strong>NumPy<\/strong>&nbsp;&#8212; \u044d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0442\u0435\u043c \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u0441 \u044f\u0437\u044b\u043a\u043e\u043c Python, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e:<\/p>\n<ol>\n<li>\n<p>\u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e&nbsp;<strong>\u0442\u0435\u043e\u0440\u0438\u0438<\/strong>&nbsp;\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440&nbsp;<strong>\u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439<\/strong>&nbsp;\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u041e\u043a\u0435\u0439, \u0437\u0432\u0443\u0447\u0438\u0442, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043a\u0430\u043a \u0447\u0442\u043e-\u0442\u043e \u043d\u0430 \u0431\u043e\u0442\u0430\u043d\u0441\u043a\u043e\u043c. \u041d\u043e \u0434\u0430\u0439\u0442\u0435 \u043c\u043d\u0435 \u0448\u0430\u043d\u0441 &#8212; \u044f \u0432\u0441\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044e (\u043d\u0438\u0436\u0435)!<\/p>\n<p><strong>\u041a\u0440\u0430\u0442\u043a\u043e \u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435<\/strong><\/p>\n<p><em>\u041f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u043f\u0446\u0438\u0438 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b: <\/em><\/p>\n<ul>\n<li>\n<p><em>\u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0437\u043e\u0440 \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, <\/em><\/p>\n<\/li>\n<li>\n<p><em>\u0438 \u043a \u043d\u0438\u043c \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0440\u0430\u0431\u043e\u0442\u044b&nbsp;<\/em><a href=\"https:\/\/www.youtube.com\/user\/AlgoRythmics\" rel=\"noopener noreferrer nofollow\"><em>\u043f\u0440\u043e\u0435\u043a\u0442\u0430 AlgoRythmics<\/em><\/a><em>&nbsp;&#8212; \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0439 (\u0434\u0430, \u044d\u0442\u043e \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043d\u0446\u0443\u044e\u0442 \u0432\u0441\u044f\u043a\u0438\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438; \u0438 \u0434\u0430, \u044f \u043f\u0440\u044f\u043c\u043e \u0431\u0435\u0437 \u0443\u043c\u0430 \u043e\u0442 \u0432\u0435\u0449\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u044e\u0442 \u0438 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u043e, \u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435!). <\/em><\/p>\n<p><em>\u041d\u0443, \u0438 \u043a\u0430\u043a \u0436\u0435 \u0431\u0435\u0437 \u043c\u0435\u043c\u043e\u0432 (\u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u044f)! <\/em><\/p>\n<p><em>\u0423\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0431\u0440\u0430\u043b&nbsp;<\/em><a href=\"https:\/\/gist.github.com\/kirlf\/f85f438116188f9c624f30c354f6929b\" rel=\"noopener noreferrer nofollow\"><em>\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/em><\/a><em>&nbsp;(\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0434\u044b \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430&nbsp;<\/em><a href=\"https:\/\/github.com\/TheAlgorithms\/Python\" rel=\"noopener noreferrer nofollow\"><em>TheAlgorithms<\/em><\/a><em>).<\/em><\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 NumPy? \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0438\u0434\u0435\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 (<a href=\"https:\/\/numpy.org\/doc\/stable\/reference\/generated\/numpy.sort.html\" rel=\"noopener noreferrer nofollow\">numpy.sort<\/a><em>() method (version <\/em>1.21<em>)<\/em>):<\/p>\n<blockquote>\n<p><em>&#8212; heapsort<\/em><\/p>\n<p><em>&#8212; mergesort<\/em><\/p>\n<p><em>&#8212; stable (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 1.15.0)<\/em><\/p>\n<p><em>&#8212; quicksort (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e)<\/em><\/p>\n<\/blockquote>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e, \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043c\u043d\u043e\u0433\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f!<\/p>\n<h3>heapsort<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c&nbsp;<strong>heapsort<\/strong>&nbsp;\u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e &#171;\u0432\u044b\u0440\u0430\u0441\u0442\u0430\u0435\u0442&#187; \u0438\u0437&nbsp;<a href=\"https:\/\/vovenur.medium.com\/numpy-sorting-and-dancing-and-memes-bf3ce0fe7c3#:~:text=directly%20relates%20to-,binary%20heaps,-(and%20this%20defines\" rel=\"noopener noreferrer nofollow\">\u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0445 \u043a\u0443\u0447&nbsp;<\/a>(<strong>binary heaps &#8212;&nbsp;<\/strong>\u043e\u0442 \u043d\u0438\u0445, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430) \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0448\u0430\u0433\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0441\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u0438\u043d\u043d\u043e\u044e&nbsp;<em>N,&nbsp;<\/em>\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432&nbsp;<strong>\u0434\u0432\u043e\u0438\u0447\u043d\u0443\u044e \u043a\u0443\u0447\u0443<\/strong>: \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u044d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f&nbsp;<em>O(N*log2(N))<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435&nbsp;<strong>min-\u043a\u0443\u0447\u0438<\/strong>&nbsp;(\u0438\u043b\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435&nbsp;<strong>max-\u043a\u0443\u0447\u0438<\/strong>) \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438\u0437 \u043a\u043e\u0440\u043d\u044f:&nbsp;<em>O(1)<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0441\u0442\u0430\u0432\u0448\u0430\u044f\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0430\u0442\u044c \u0441\u043d\u043e\u0432\u0430 \u043a\u0443\u0447\u0435\u0439:&nbsp;<em>O(log2(N))<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0434\u0432\u0430 \u0448\u0430\u0433\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f<em>&nbsp;N<\/em>&nbsp;\u0440\u0430\u0437.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0431\u0449\u0430\u044f \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442&nbsp;<em>O(N*log2(N))&nbsp;<\/em>(\u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435,&nbsp;<em>O(2N*log2(N)),&nbsp;<\/em>\u043d\u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u043c\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0433\u0430\u0442\u044c)<em>.<\/em><\/p>\n<p>\u041f\u043e\u0442\u0430\u043d\u0446\u0443\u0435\u043c?<\/p>\n<p><iframe id=\"60f48ff012b0d58fd6dde636\" src=\"https:\/\/embedd.srv.habr.com\/iframe\/60f48ff012b0d58fd6dde636\" class=\"embed_video embed__content\" allowfullscreen=\"true\"><\/iframe><\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f&nbsp;<strong>heapsort<\/strong>&nbsp;\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c min-\u043a\u0443\u0447 \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0430\u043c\u043e\u0433\u043e Python (\u0441\u043c. \u043c\u043e\u0434\u0443\u043b\u044c&nbsp;<a href=\"https:\/\/docs.python.org\/3\/library\/heapq.html#basic-examples\" rel=\"noopener noreferrer nofollow\">heapq<\/a>).<\/p>\n<p><em>\u0410 \u0435\u0449\u0435 \u0432 \u043d\u0430\u0448\u0435\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0435 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430\u0445 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0442\u0435\u0440\u043c\u0438\u043d &#171;\u043f\u0438\u0440\u0430\u043c\u0438\u0434\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430&#187; &#8212; \u044d\u0442\u043e \u043e\u043d\u0430 \u0436\u0435, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043a\u0443\u0447\u0435\u0439, heapsort.<\/em><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e0c\/850\/c16\/e0c850c1624c6ed597efa28ed74b24e6.png\" width=\"1080\" height=\"685\"><figcaption><\/figcaption><\/figure>\n<h3>mergesort<\/h3>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f&nbsp;<strong>\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c<\/strong>&nbsp;(<strong>mergesort),&nbsp;<\/strong>\u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439<strong>&nbsp;<\/strong>\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0434\u0440\u0435\u0432\u043d\u0435\u0439 \u043f\u043e\u0441\u043b\u043e\u0432\u0438\u0446\u0435\u0439 \u201c\u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0439 \u0438 \u0432\u043b\u0430\u0441\u0442\u0432\u0443\u0439\u201d:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 (\u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a) \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0432\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u0447\u0430\u0441\u0442\u0435\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0442\u043e\u0439 \u0436\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u043e\u0439 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0441\u043d\u043e\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0430 \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438);<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1ec\/f37\/51e\/1ecf3751edf2123d7784977c7f7477af.png\" width=\"464\" height=\"360\"><figcaption><\/figcaption><\/figure>\n<p>Credits: ITMO University<\/p>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0436\u043d\u044b\u0445 \u0444\u0430\u043a\u0442\u043e\u0432 \u043e&nbsp;<strong>\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430 \u0434\u043b\u044f \u0445\u0443\u0434\u0448\u0435\u0433\u043e, \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0435\u0432:&nbsp;<em>O(N*log2(N))<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u0442\u0440\u0435\u0431\u0443\u0435\u0442&nbsp;<em>O(N)<\/em>&nbsp;\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 (\u043d\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0432\u044f\u0437\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0433\u0434\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u0443\u0437\u043b\u044b, \u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0440\u043e\u043b\u0438 \u043d\u0435 \u0438\u0433\u0440\u0430\u0435\u0442);<\/p>\n<\/li>\n<li>\n<p>\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0442\u0435\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u043e\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e \u0441\u0432\u044f\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438);<\/p>\n<\/li>\n<li>\n<p><strong>\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0430\u044f (stable)&nbsp;<\/strong>&#8212;<strong>&nbsp;<\/strong>\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u0440\u0430\u0432\u043d\u043e\u043f\u0440\u0430\u0432\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 (\u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043a\u043b\u044e\u0447\u0438 \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u043a \u0440\u0430\u0437\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c (\u0446\u0435\u043d\u044b \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u044b &#8212; \u043a\u043b\u044e\u0447\u0438, \u0441\u0430\u043c\u0438 \u043c\u0430\u0448\u0438\u043d\u044b &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f) \u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u0442\u0440\u043e\u043d\u0443\u0442\u044b\u043c).<\/p>\n<\/li>\n<\/ul>\n<p><iframe id=\"60f4902712b0d58fd6dde637\" src=\"https:\/\/embedd.srv.habr.com\/iframe\/60f4902712b0d58fd6dde637\" class=\"embed_video embed__content\" allowfullscreen=\"true\"><\/iframe><\/p>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434&#8230; \u041e\u0434\u043d\u0430\u043a\u043e, \u0447\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<blockquote>\n<p><em>New in version 1.17.0.<\/em><\/p>\n<p><em>Timsort is added for better performance on already or nearly sorted data. On random data timsort is almost identical to mergesort. It is now used for stable sort while quicksort is still the default sort if none is chosen. For timsort details, refer to&nbsp;<\/em><a href=\"https:\/\/github.com\/python\/cpython\/blob\/3.7\/Objects\/listsort.txt\" rel=\"noopener noreferrer nofollow\"><em>CPython listsort.txt<\/em><\/a><em>. \u2018mergesort\u2019 and \u2018stable\u2019 are mapped to radix sort for integer data types. Radix sort is an O(n) sort instead of O(n log n).<\/em><\/p>\n<\/blockquote>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c:<\/p>\n<ol>\n<li>\n<p>\u041e\u043f\u0446\u0438\u0438<strong>&nbsp;mergesort<\/strong>&nbsp;\u0438&nbsp;<strong>stable<\/strong>&nbsp;\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e\u0436\u0435 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 numpy.sort();<\/p>\n<\/li>\n<li>\n<p>\u0413\u0438\u0431\u0440\u0438\u0434\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430&nbsp;<a href=\"https:\/\/ru.wikipedia.org\/wiki\/Timsort\" rel=\"noopener noreferrer nofollow\"><strong>Timsort<\/strong><\/a><strong>&nbsp;<\/strong>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u201c\u0447\u0438\u0441\u0442\u043e\u0439\u201d&nbsp;<strong>mergesort&nbsp;<\/strong>(\u0442\u0430\u043a\u0430\u044f \u0436\u0435, \u043a\u0430\u043a \u0432 \u043c\u0435\u0442\u043e\u0434\u0435&nbsp;<a href=\"https:\/\/docs.python.org\/3\/library\/stdtypes.html#list.sort\" rel=\"noopener noreferrer nofollow\">sort()<\/a>&nbsp;\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438&nbsp;<a href=\"https:\/\/docs.python.org\/3\/howto\/sorting.html\" rel=\"noopener noreferrer nofollow\">sorted()<\/a>&nbsp;CPython);<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 &#8212; \u044d\u0442\u043e \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 (int), \u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u0440\u0430\u0437\u0440\u044f\u0434\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 (<strong>radix sort<\/strong>), \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0449\u0430\u044f O(N) \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u043f\u0440\u043e\u0441\u0442\u043e &#171;\u043e\u0442\u0432\u0430\u043b \u0431\u0430\u0448\u043a\u0438&#187;!).<\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u0430\u044f Timsort, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u0435&nbsp;<strong>\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0432\u0441\u0442\u0430\u0432\u043a\u0430\u043c\u0438 (insertion sort)&nbsp;<\/strong>\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0441\u043c. \u0437\u0434\u0435\u0441\u044c:&nbsp;<a href=\"https:\/\/github.com\/python\/cpython\/blob\/3.7\/Objects\/listsort.txt\" rel=\"noopener noreferrer nofollow\">CPython listsort.txt<\/a>).<\/p>\n<p><iframe id=\"60f4905a2077cda25f846ae8\" src=\"https:\/\/embedd.srv.habr.com\/iframe\/60f4905a2077cda25f846ae8\" class=\"embed_video embed__content\" allowfullscreen=\"true\"><\/iframe><\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0441\u0430\u043c\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0446\u0438\u0438 (<strong>mergesort<\/strong>) &#8212; \u044d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u0441\u043b\u0435\u0434\u0438\u044f  \u0432 \u0446\u0435\u043b\u044f\u0445 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438. &#171;\u041f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c&#187; \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u0435\u0449\u0438.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cac\/1f8\/d7a\/cac1f8d7a5aa5e4b4dbb0c698b6fb464.png\" width=\"500\" height=\"277\"><figcaption><\/figcaption><\/figure>\n<h3>quicksort<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0430\u0437\u043e\u0432. \u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u0442\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f&nbsp;<strong>\u0431\u044b\u0441\u0442\u0440\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 (quicksort)<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442&nbsp;<em>\u043e\u043f\u043e\u0440\u043d\u044b\u0439<\/em>&nbsp;(<em>pivot)<\/em>&nbsp;\u044d\u043b\u0435\u043c\u0435\u043d\u0442;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043d\u0430 \u0442\u0440\u0438 \u0433\u0440\u0443\u043f\u043f\u044b: \u201c\u043c\u0435\u043d\u044c\u0448\u0435\u201d, \u201c\u0431\u043e\u043b\u044c\u0448\u0435\u201d \u0438 \u201c\u0440\u0430\u0432\u043d\u043e\u201d \u043e\u043f\u043e\u0440\u043d\u043e\u0433\u043e(\u043e\u043c\u0443) \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430(\u0443);<\/p>\n<\/li>\n<li>\n<p><strong>\u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e<\/strong>&nbsp;\u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0435\u0431\u044f \u0441\u0430\u043c\u0443 \u0436\u0435 \u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u0433\u0440\u0443\u043f\u043f\u0430\u043c.<\/p>\n<\/li>\n<\/ul>\n<p><iframe id=\"60f49097920526a288c7e15a\" src=\"https:\/\/embedd.srv.habr.com\/iframe\/60f49097920526a288c7e15a\" class=\"embed_video embed__content\" allowfullscreen=\"true\"><\/iframe><\/p>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u043a\u0442\u043e\u0432 \u043e&nbsp;<strong>\u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c:&nbsp;<em>O(N*log2(N))<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u0445\u0443\u0434\u0448\u0430\u044f \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c:&nbsp;<em>O(N\u00b2)<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0430\u043b\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438:&nbsp;<em>O(log2(N))<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u044f\u0437\u044b\u043a\u0430 C (<a href=\"https:\/\/www.opennet.ru\/man.shtml?topic=qsort&amp;category=3&amp;russian=0\" rel=\"noopener noreferrer nofollow\">qsort()<\/a>);<\/p>\n<\/li>\n<li>\n<p><strong>\u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e! \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u0430\u043d\u043d\u0430\u044f \u043e\u043f\u0446\u0438\u044f \u0442\u043e\u0436\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438:<\/p>\n<blockquote>\n<p><em>New in version 1.12.0.<\/em><\/p>\n<p><em>quicksort has been changed to introsort. When sorting does not make enough progress it switches to heapsort. This implementation makes quicksort O(n*log(n)) in the worst case.<\/em><\/p>\n<\/blockquote>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u043e\u043f\u0446\u0438\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Introsort\" rel=\"noopener noreferrer nofollow\"><strong>introsort<\/strong><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043b\u0438\u0431\u043e \u0431\u044b\u0441\u0442\u0440\u0443\u044e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443, \u043b\u0438\u0431\u043e \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432 (\u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0433\u043b\u0443\u0431\u0438\u043d\u044b \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 &#8212; \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0430\u044f, \u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f).<\/p>\n<p><em>\u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441, \u0430 \u0437\u0430\u0447\u0435\u043c \u0442\u043e\u0433\u0434\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0447\u0438\u0441\u0442\u0443\u044e heapsort?  \u042f \u0432\u043e\u0442&nbsp;<\/em><a href=\"https:\/\/datascience.stackexchange.com\/questions\/89641\/what-are-the-use-cases-for-heapsort-option-in-numpy-sort\" rel=\"noopener noreferrer nofollow\"><em>\u0437\u0430\u0434\u0430\u043b\u0441\u044f \u044d\u0442\u0438\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c<\/em><\/a><em>, \u043d\u043e \u0434\u0443\u043c\u0430\u044e \u0440\u0430\u0437\u0433\u0430\u0434\u043a\u0430 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430: \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438.<\/em><\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/09a\/3aa\/34e\/09a3aa34e88eff7e37dabae0ec11c7dc.png\" width=\"600\" height=\"347\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0434\u0432\u0435\u0434\u0435\u043c \u0438\u0442\u043e\u0433\u0438:<\/p>\n<ol>\n<li>\n<p><strong>\u0422\u0435\u043e\u0440\u0438\u044f<\/strong>: \u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0438 \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 NumPy &#8212; \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u043e\u0432\u043e\u0434 \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/strong>: \u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0438 \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 NumPy \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u044c, \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0442\u0441\u044f, \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0435 \u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0430\u043c\u0438 \u0438 \u0443\u0447\u0435\u043d\u044b\u043c\u0438 \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u041c\u0438\u0440\u0443 (\u043e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434&nbsp;<a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/reference\/api\/pandas.DataFrame.sort_values.html\" rel=\"noopener noreferrer nofollow\">pandas.DataFrame.sort_values<\/a>&nbsp;\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u043e\u0442 \u0436\u0435 \u043f\u0443\u043b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432).<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043c\u043e\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u0437\u043e\u0440 \u0431\u044b\u043b \u0432\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u0435\u043d, \u0438 \u0434\u0430 \u043f\u0440\u0435\u0431\u0443\u0434\u0435\u0442 \u0441 \u0432\u0430\u043c\u0438 \u0441\u0438\u043b\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438!<\/p>\n<p>P.S.<\/p>\n<p>\u0418 \u0434\u0430, \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u0432\u044b \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u044e <strong>stable <\/strong>(\u0438\u043b\u0438<strong> mergesort <\/strong>\u043f\u043e \u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435), \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430; \u0438\u043b\u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0435\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c (\u0438 \u0442\u043e\u0433\u0434\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u0442 <em>quicksort<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 <strong>introsort<\/strong>), \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 &#8212; \u0438 \u0432\u0441\u0451. \u041d\u043e, \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u043a\u0430\u043a \u0436\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0432 \u0447\u0435\u043c-\u0442\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f! <\/p>\n<h3>\u041b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0430<\/h3>\n<ol>\n<li>\n<p>\u0421\u0442\u0438\u0432\u0435\u043d\u0441, \u0420., 2016. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435. \u041c.: \u0418\u0437\u0434\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u00ab\u042d.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0435\u0434\u0436\u0432\u0438\u043a, \u0420., 2001. \u0424\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043d\u0430 \u0421++. \u041a.: \u0414\u0438\u0430\u0441\u043e\u0444\u0442.<\/p>\n<\/li>\n<\/ol>\n<h3>\u0420\u0435\u0441\u0443\u0440\u0441\u044b \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432<\/h3>\n<ol>\n<li>\n<p><a href=\"http:\/\/sorting.at\/\" rel=\"noopener noreferrer nofollow\">SORTING.at<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.toptal.com\/developers\/sorting-algorithms\" rel=\"noopener noreferrer nofollow\">Sorting Algorithms Animations<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.cs.usfca.edu\/~galles\/visualization\/Heap.html\" rel=\"noopener noreferrer nofollow\">Min Heap sort<\/a><\/p>\n<\/li>\n<\/ol>\n<h3>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h3>\n<ol>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/335920\/\" rel=\"noopener noreferrer nofollow\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/academy.yandex.ru\/posts\/osnovnye-vidy-sortirovok-i-primery-ikh-realizatsii\" rel=\"noopener noreferrer nofollow\">\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043e\u043a \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/a><\/p>\n<\/li>\n<\/ol>\n<h3>\u0412\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0430\u0442<\/h3>\n<ol>\n<li>\n<p><a href=\"https:\/\/vovenur.medium.com\/numpy-sorting-and-dancing-and-memes-bf3ce0fe7c3\" rel=\"noopener noreferrer nofollow\">NumPy sorting (and dancing and memes)<\/a>&nbsp;(Medium)<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.slideshare.net\/VladimirFadeev4\/numpy-sorting-and-dancing-and-memes-a-short-review-for-students\" rel=\"noopener noreferrer nofollow\">NumPy sorting (and dancing and memes): \u200b a short review for students<\/a>\u200b (SlideShare)<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/568482\/\"> https:\/\/habr.com\/ru\/post\/568482\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p><strong>\u0412\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u044f<\/strong>: <\/p>\n<p>\u0414\u0430, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043d\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u0431\u0438\u0442\u043e\u0439 \u0442\u0435\u043c\u044b, \u0447\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u0435\u043d\u044f \u0432 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0442\u0430\u043a \u0443\u0432\u043b\u0435\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u044b \u0432 NumPy, \u0447\u0442\u043e \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0432\u0441\u0435\u043c \u043e\u0431 \u044d\u0442\u043e\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u043b\u043a\u0430\u044f \u0432\u0435\u0449\u044c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0437\u0430\u043d\u0443\u0434\u0441\u0442\u0432\u043e \u043a\u0430\u043a\u043e\u0435-\u0442\u043e, \u043d\u043e \u0442\u0435\u0448\u0443 \u0441\u0435\u0431\u044f \u043d\u0430\u0434\u0435\u0436\u0434\u043e\u0439, \u0447\u0442\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0442\u0435\u043c\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b! \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u043b\u044e\u0434\u0435\u0439, \u043a\u0430\u043a \u044f, \u043f\u0435\u0440\u0435\u0448\u0435\u0434\u0448\u0438\u0445 \u0438\u0437 \u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u0441\u0444\u0435\u0440 (\u0438\u0437 \u0442\u0435\u043b\u0435\u043a\u043e\u043c\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440), \u0433\u0434\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u043d\u0435 \u0438\u0437\u0443\u0447\u0430\u0442\u044c\u0441\u044f (\u0431\u044b\u0432\u0430\u0435\u0442 \u0438 \u0442\u0430\u043a\u043e\u0435). \u0415\u0441\u043b\u0438 \u0433\u0434\u0435-\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0430\u043f\u0443\u0442\u0430\u043b (\u0438\u043b\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0434\u043b\u044f \u0432\u0430\u0441 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c), \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0438!<\/p>\n<figure class=\"full-width\"><figcaption> <\/figcaption><\/figure>\n<p>\u0418\u0442\u0430\u043a<em>, <\/em>\u044f \u0438\u0441\u043a\u0440\u0435\u043d\u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0442\u0435\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438&nbsp;<strong>\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438<\/strong>&nbsp;\u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438&nbsp;<strong>NumPy<\/strong>&nbsp;&#8212; \u044d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0442\u0435\u043c \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u0441 \u044f\u0437\u044b\u043a\u043e\u043c Python, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e:<\/p>\n<ol>\n<li>\n<p>\u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e&nbsp;<strong>\u0442\u0435\u043e\u0440\u0438\u0438<\/strong>&nbsp;\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440&nbsp;<strong>\u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439<\/strong>&nbsp;\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u041e\u043a\u0435\u0439, \u0437\u0432\u0443\u0447\u0438\u0442, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043a\u0430\u043a \u0447\u0442\u043e-\u0442\u043e \u043d\u0430 \u0431\u043e\u0442\u0430\u043d\u0441\u043a\u043e\u043c. \u041d\u043e \u0434\u0430\u0439\u0442\u0435 \u043c\u043d\u0435 \u0448\u0430\u043d\u0441 &#8212; \u044f \u0432\u0441\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u044e (\u043d\u0438\u0436\u0435)!<\/p>\n<p><strong>\u041a\u0440\u0430\u0442\u043a\u043e \u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435<\/strong><\/p>\n<p><em>\u041f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u043f\u0446\u0438\u0438 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b: <\/em><\/p>\n<ul>\n<li>\n<p><em>\u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0437\u043e\u0440 \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, <\/em><\/p>\n<\/li>\n<li>\n<p><em>\u0438 \u043a \u043d\u0438\u043c \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0440\u0430\u0431\u043e\u0442\u044b&nbsp;<\/em><a href=\"https:\/\/www.youtube.com\/user\/AlgoRythmics\" rel=\"noopener noreferrer nofollow\"><em>\u043f\u0440\u043e\u0435\u043a\u0442\u0430 AlgoRythmics<\/em><\/a><em>&nbsp;&#8212; \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0439 (\u0434\u0430, \u044d\u0442\u043e \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0430\u043d\u0446\u0443\u044e\u0442 \u0432\u0441\u044f\u043a\u0438\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438; \u0438 \u0434\u0430, \u044f \u043f\u0440\u044f\u043c\u043e \u0431\u0435\u0437 \u0443\u043c\u0430 \u043e\u0442 \u0432\u0435\u0449\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u044e\u0442 \u0438 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u043e, \u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435!). <\/em><\/p>\n<p><em>\u041d\u0443, \u0438 \u043a\u0430\u043a \u0436\u0435 \u0431\u0435\u0437 \u043c\u0435\u043c\u043e\u0432 (\u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u044f)! <\/em><\/p>\n<p><em>\u0423\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0431\u0440\u0430\u043b&nbsp;<\/em><a href=\"https:\/\/gist.github.com\/kirlf\/f85f438116188f9c624f30c354f6929b\" rel=\"noopener noreferrer nofollow\"><em>\u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/em><\/a><em>&nbsp;(\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043a\u043e\u0434\u044b \u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430&nbsp;<\/em><a href=\"https:\/\/github.com\/TheAlgorithms\/Python\" rel=\"noopener noreferrer nofollow\"><em>TheAlgorithms<\/em><\/a><em>).<\/em><\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 NumPy? \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0438\u0434\u0435\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 (<a href=\"https:\/\/numpy.org\/doc\/stable\/reference\/generated\/numpy.sort.html\" rel=\"noopener noreferrer nofollow\">numpy.sort<\/a><em>() method (version <\/em>1.21<em>)<\/em>):<\/p>\n<blockquote>\n<p><em>&#8212; heapsort<\/em><\/p>\n<p><em>&#8212; mergesort<\/em><\/p>\n<p><em>&#8212; stable (\u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 1.15.0)<\/em><\/p>\n<p><em>&#8212; quicksort (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e)<\/em><\/p>\n<\/blockquote>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e, \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043c\u043d\u043e\u0433\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f!<\/p>\n<h3>heapsort<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c&nbsp;<strong>heapsort<\/strong>&nbsp;\u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e &#171;\u0432\u044b\u0440\u0430\u0441\u0442\u0430\u0435\u0442&#187; \u0438\u0437&nbsp;<a href=\"https:\/\/vovenur.medium.com\/numpy-sorting-and-dancing-and-memes-bf3ce0fe7c3#:~:text=directly%20relates%20to-,binary%20heaps,-(and%20this%20defines\" rel=\"noopener noreferrer nofollow\">\u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0445 \u043a\u0443\u0447&nbsp;<\/a>(<strong>binary heaps &#8212;&nbsp;<\/strong>\u043e\u0442 \u043d\u0438\u0445, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430) \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0448\u0430\u0433\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0435\u0441\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u0438\u043d\u043d\u043e\u044e&nbsp;<em>N,&nbsp;<\/em>\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d;<\/p>\n<\/li>\n<li>\n<p>\u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432&nbsp;<strong>\u0434\u0432\u043e\u0438\u0447\u043d\u0443\u044e \u043a\u0443\u0447\u0443<\/strong>: \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u044d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f&nbsp;<em>O(N*log2(N))<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435&nbsp;<strong>min-\u043a\u0443\u0447\u0438<\/strong>&nbsp;(\u0438\u043b\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435&nbsp;<strong>max-\u043a\u0443\u0447\u0438<\/strong>) \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438\u0437 \u043a\u043e\u0440\u043d\u044f:&nbsp;<em>O(1)<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0441\u0442\u0430\u0432\u0448\u0430\u044f\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0430\u0442\u044c \u0441\u043d\u043e\u0432\u0430 \u043a\u0443\u0447\u0435\u0439:&nbsp;<em>O(log2(N))<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0434\u0432\u0430 \u0448\u0430\u0433\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f<em>&nbsp;N<\/em>&nbsp;\u0440\u0430\u0437.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0431\u0449\u0430\u044f \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442&nbsp;<em>O(N*log2(N))&nbsp;<\/em>(\u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435,&nbsp;<em>O(2N*log2(N)),&nbsp;<\/em>\u043d\u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u043c\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0433\u0430\u0442\u044c)<em>.<\/em><\/p>\n<p>\u041f\u043e\u0442\u0430\u043d\u0446\u0443\u0435\u043c?<\/p>\n<p><iframe id=\"60f48ff012b0d58fd6dde636\" src=\"https:\/\/embedd.srv.habr.com\/iframe\/60f48ff012b0d58fd6dde636\" class=\"embed_video embed__content\" allowfullscreen=\"true\"><\/iframe><\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f&nbsp;<strong>heapsort<\/strong>&nbsp;\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c min-\u043a\u0443\u0447 \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0430\u043c\u043e\u0433\u043e Python (\u0441\u043c. \u043c\u043e\u0434\u0443\u043b\u044c&nbsp;<a href=\"https:\/\/docs.python.org\/3\/library\/heapq.html#basic-examples\" rel=\"noopener noreferrer nofollow\">heapq<\/a>).<\/p>\n<p><em>\u0410 \u0435\u0449\u0435 \u0432 \u043d\u0430\u0448\u0435\u0439 \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0435 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430\u0445 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0442\u0435\u0440\u043c\u0438\u043d &#171;\u043f\u0438\u0440\u0430\u043c\u0438\u0434\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430&#187; &#8212; \u044d\u0442\u043e \u043e\u043d\u0430 \u0436\u0435, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043a\u0443\u0447\u0435\u0439, heapsort.<\/em><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>mergesort<\/h3>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f&nbsp;<strong>\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c<\/strong>&nbsp;(<strong>mergesort),&nbsp;<\/strong>\u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439<strong>&nbsp;<\/strong>\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0434\u0440\u0435\u0432\u043d\u0435\u0439 \u043f\u043e\u0441\u043b\u043e\u0432\u0438\u0446\u0435\u0439 \u201c\u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0439 \u0438 \u0432\u043b\u0430\u0441\u0442\u0432\u0443\u0439\u201d:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 (\u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a) \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0432\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b;<\/p>\n<\/li>\n<li>\n<p>\u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u0447\u0430\u0441\u0442\u0435\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0442\u043e\u0439 \u0436\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u043e\u0439 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0441\u043d\u043e\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0430 \u043d\u0430 \u0434\u0432\u0435 \u0447\u0430\u0441\u0442\u0438);<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>Credits: ITMO University<\/p>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0436\u043d\u044b\u0445 \u0444\u0430\u043a\u0442\u043e\u0432 \u043e&nbsp;<strong>\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430 \u0434\u043b\u044f \u0445\u0443\u0434\u0448\u0435\u0433\u043e, \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0435\u0432:&nbsp;<em>O(N*log2(N))<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u0442\u0440\u0435\u0431\u0443\u0435\u0442&nbsp;<em>O(N)<\/em>&nbsp;\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 (\u043d\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0432\u044f\u0437\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0433\u0434\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u0443\u0437\u043b\u044b, \u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0440\u043e\u043b\u0438 \u043d\u0435 \u0438\u0433\u0440\u0430\u0435\u0442);<\/p>\n<\/li>\n<li>\n<p>\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0442\u0435\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u043e\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e \u0441\u0432\u044f\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u0438\u0441\u043a\u0430\u043c\u0438);<\/p>\n<\/li>\n<li>\n<p><strong>\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0430\u044f (stable)&nbsp;<\/strong>&#8212;<strong>&nbsp;<\/strong>\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u0440\u0430\u0432\u043d\u043e\u043f\u0440\u0430\u0432\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 (\u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043a\u043b\u044e\u0447\u0438 \u0432\u0435\u0434\u0443\u0449\u0438\u0435 \u043a \u0440\u0430\u0437\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c (\u0446\u0435\u043d\u044b \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u044b &#8212; \u043a\u043b\u044e\u0447\u0438, \u0441\u0430\u043c\u0438 \u043c\u0430\u0448\u0438\u043d\u044b &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f) \u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u0442\u0440\u043e\u043d\u0443\u0442\u044b\u043c).<\/p>\n<\/li>\n<\/ul>\n<p><iframe id=\"60f4902712b0d58fd6dde637\" src=\"https:\/\/embedd.srv.habr.com\/iframe\/60f4902712b0d58fd6dde637\" class=\"embed_video embed__content\" allowfullscreen=\"true\"><\/iframe><\/p>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434&#8230; \u041e\u0434\u043d\u0430\u043a\u043e, \u0447\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f:<\/p>\n<blockquote>\n<p><em>New in version 1.17.0.<\/em><\/p>\n<p><em>Timsort is added for better performance on already or nearly sorted data. On random data timsort is almost identical to mergesort. It is now used for stable sort while quicksort is still the default sort if none is chosen. For timsort details, refer to&nbsp;<\/em><a href=\"https:\/\/github.com\/python\/cpython\/blob\/3.7\/Objects\/listsort.txt\" rel=\"noopener noreferrer nofollow\"><em>CPython listsort.txt<\/em><\/a><em>. \u2018mergesort\u2019 and \u2018stable\u2019 are mapped to radix sort for integer data types. Radix sort is an O(n) sort instead of O(n log n).<\/em><\/p>\n<\/blockquote>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c:<\/p>\n<ol>\n<li>\n<p>\u041e\u043f\u0446\u0438\u0438<strong>&nbsp;mergesort<\/strong>&nbsp;\u0438&nbsp;<strong>stable<\/strong>&nbsp;\u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e\u0436\u0435 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 numpy.sort();<\/p>\n<\/li>\n<li>\n<p>\u0413\u0438\u0431\u0440\u0438\u0434\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430&nbsp;<a href=\"https:\/\/ru.wikipedia.org\/wiki\/Timsort\" rel=\"noopener noreferrer nofollow\"><strong>Timsort<\/strong><\/a><strong>&nbsp;<\/strong>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u201c\u0447\u0438\u0441\u0442\u043e\u0439\u201d&nbsp;<strong>mergesort&nbsp;<\/strong>(\u0442\u0430\u043a\u0430\u044f \u0436\u0435, \u043a\u0430\u043a \u0432 \u043c\u0435\u0442\u043e\u0434\u0435&nbsp;<a href=\"https:\/\/docs.python.org\/3\/library\/stdtypes.html#list.sort\" rel=\"noopener noreferrer nofollow\">sort()<\/a>&nbsp;\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438&nbsp;<a href=\"https:\/\/docs.python.org\/3\/howto\/sorting.html\" rel=\"noopener noreferrer nofollow\">sorted()<\/a>&nbsp;CPython);<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 &#8212; \u044d\u0442\u043e \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 (int), \u0442\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u0440\u0430\u0437\u0440\u044f\u0434\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 (<strong>radix sort<\/strong>), \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0449\u0430\u044f O(N) \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u043f\u0440\u043e\u0441\u0442\u043e &#171;\u043e\u0442\u0432\u0430\u043b \u0431\u0430\u0448\u043a\u0438&#187;!).<\/p>\n<\/li>\n<\/ol>\n<p>\u0410 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u0430\u044f Timsort, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u0435&nbsp;<strong>\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0432\u0441\u0442\u0430\u0432\u043a\u0430\u043c\u0438 (insertion sort)&nbsp;<\/strong>\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0441\u043c. \u0437\u0434\u0435\u0441\u044c:&nbsp;<a href=\"https:\/\/github.com\/python\/cpython\/blob\/3.7\/Objects\/listsort.txt\" rel=\"noopener noreferrer nofollow\">CPython listsort.txt<\/a>).<\/p>\n<p><iframe id=\"60f4905a2077cda25f846ae8\" src=\"https:\/\/embedd.srv.habr.com\/iframe\/60f4905a2077cda25f846ae8\" class=\"embed_video embed__content\" allowfullscreen=\"true\"><\/iframe><\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0441\u0430\u043c\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0446\u0438\u0438 (<strong>mergesort<\/strong>) &#8212; \u044d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u0441\u043b\u0435\u0434\u0438\u044f  \u0432 \u0446\u0435\u043b\u044f\u0445 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438. &#171;\u041f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c&#187; \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u0435\u0449\u0438.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<h3>quicksort<\/h3>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0430\u0437\u043e\u0432. \u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u0442\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f&nbsp;<strong>\u0431\u044b\u0441\u0442\u0440\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 (quicksort)<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442&nbsp;<em>\u043e\u043f\u043e\u0440\u043d\u044b\u0439<\/em>&nbsp;(<em>pivot)<\/em>&nbsp;\u044d\u043b\u0435\u043c\u0435\u043d\u0442;<\/p>\n<\/li>\n<li>\n<p>\u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043d\u0430 \u0442\u0440\u0438 \u0433\u0440\u0443\u043f\u043f\u044b: \u201c\u043c\u0435\u043d\u044c\u0448\u0435\u201d, \u201c\u0431\u043e\u043b\u044c\u0448\u0435\u201d \u0438 \u201c\u0440\u0430\u0432\u043d\u043e\u201d \u043e\u043f\u043e\u0440\u043d\u043e\u0433\u043e(\u043e\u043c\u0443) \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430(\u0443);<\/p>\n<\/li>\n<li>\n<p><strong>\u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e<\/strong>&nbsp;\u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0435\u0431\u044f \u0441\u0430\u043c\u0443 \u0436\u0435 \u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u0433\u0440\u0443\u043f\u043f\u0430\u043c.<\/p>\n<\/li>\n<\/ul>\n<p><iframe id=\"60f49097920526a288c7e15a\" src=\"https:\/\/embedd.srv.habr.com\/iframe\/60f49097920526a288c7e15a\" class=\"embed_video embed__content\" allowfullscreen=\"true\"><\/iframe><\/p>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u043a\u0442\u043e\u0432 \u043e&nbsp;<strong>\u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c:&nbsp;<em>O(N*log2(N))<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u0445\u0443\u0434\u0448\u0430\u044f \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c:&nbsp;<em>O(N\u00b2)<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0430\u043b\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438:&nbsp;<em>O(log2(N))<\/em>;<\/p>\n<\/li>\n<li>\n<p>\u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u044f\u0437\u044b\u043a\u0430 C (<a href=\"https:\/\/www.opennet.ru\/man.shtml?topic=qsort&amp;category=3&amp;russian=0\" rel=\"noopener noreferrer nofollow\">qsort()<\/a>);<\/p>\n<\/li>\n<li>\n<p><strong>\u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e! \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u0430\u043d\u043d\u0430\u044f \u043e\u043f\u0446\u0438\u044f \u0442\u043e\u0436\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438:<\/p>\n<blockquote>\n<p><em>New in version 1.12.0.<\/em><\/p>\n<p><em>quicksort has been changed to introsort. When sorting does not make enough progress it switches to heapsort. This implementation makes quicksort O(n*log(n)) in the worst case.<\/em><\/p>\n<\/blockquote>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u043e\u043f\u0446\u0438\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Introsort\" rel=\"noopener noreferrer nofollow\"><strong>introsort<\/strong><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043b\u0438\u0431\u043e \u0431\u044b\u0441\u0442\u0440\u0443\u044e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443, \u043b\u0438\u0431\u043e \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432 (\u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0433\u043b\u0443\u0431\u0438\u043d\u044b \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 &#8212; \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0430\u044f, \u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f).<\/p>\n<p><em>\u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441, \u0430 \u0437\u0430\u0447\u0435\u043c \u0442\u043e\u0433\u0434\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0447\u0438\u0441\u0442\u0443\u044e heapsort?  \u042f \u0432\u043e\u0442&nbsp;<\/em><a href=\"https:\/\/datascience.stackexchange.com\/questions\/89641\/what-are-the-use-cases-for-heapsort-option-in-numpy-sort\" rel=\"noopener noreferrer nofollow\"><em>\u0437\u0430\u0434\u0430\u043b\u0441\u044f \u044d\u0442\u0438\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c<\/em><\/a><em>, \u043d\u043e \u0434\u0443\u043c\u0430\u044e \u0440\u0430\u0437\u0433\u0430\u0434\u043a\u0430 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430: \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438.<\/em><\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0434\u0432\u0435\u0434\u0435\u043c \u0438\u0442\u043e\u0433\u0438:<\/p>\n<ol>\n<li>\n<p><strong>\u0422\u0435\u043e\u0440\u0438\u044f<\/strong>: \u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0438 \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 NumPy &#8212; \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u043e\u0432\u043e\u0434 \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/strong>: \u0447\u0442\u0435\u043d\u0438\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0438 \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 NumPy \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0441\u043b\u0435\u0434\u0438\u0442\u044c, \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0442\u0441\u044f, \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0435 \u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0430\u043c\u0438 \u0438 \u0443\u0447\u0435\u043d\u044b\u043c\u0438 \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u041c\u0438\u0440\u0443 (\u043e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434&nbsp;<a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/reference\/api\/pandas.DataFrame.sort_values.html\" rel=\"noopener noreferrer nofollow\">pandas.DataFrame.sort_values<\/a>&nbsp;\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u043e\u0442 \u0436\u0435 \u043f\u0443\u043b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432).<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043c\u043e\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u0437\u043e\u0440 \u0431\u044b\u043b \u0432\u0430\u043c \u043f\u043e\u043b\u0435\u0437\u0435\u043d, \u0438 \u0434\u0430 \u043f\u0440\u0435\u0431\u0443\u0434\u0435\u0442 \u0441 \u0432\u0430\u043c\u0438 \u0441\u0438\u043b\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438!<\/p>\n<p>P.S.<\/p>\n<p>\u0418 \u0434\u0430, \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u0432\u044b \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u044e <strong>stable <\/strong>(\u0438\u043b\u0438<strong> mergesort <\/strong>\u043f\u043e \u0441\u0442\u0430\u0440\u0438\u043d\u043a\u0435), \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430; \u0438\u043b\u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0435\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c (\u0438 \u0442\u043e\u0433\u0434\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0435\u0442 <em>quicksort<\/em>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 <strong>introsort<\/strong>), \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u0430\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u0430 &#8212; \u0438 \u0432\u0441\u0451. \u041d\u043e, \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u043a\u0430\u043a \u0436\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0432 \u0447\u0435\u043c-\u0442\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f! <\/p>\n<h3>\u041b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0430<\/h3>\n<ol>\n<li>\n<p>\u0421\u0442\u0438\u0432\u0435\u043d\u0441, \u0420., 2016. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435. \u041c.: \u0418\u0437\u0434\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u00ab\u042d.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0435\u0434\u0436\u0432\u0438\u043a, \u0420., 2001. \u0424\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043d\u0430 \u0421++. \u041a.: \u0414\u0438\u0430\u0441\u043e\u0444\u0442.<\/p>\n<\/li>\n<\/ol>\n<h3>\u0420\u0435\u0441\u0443\u0440\u0441\u044b \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432<\/h3>\n<ol>\n<li>\n<p><a href=\"http:\/\/sorting.at\/\" rel=\"noopener noreferrer nofollow\">SORTING.at<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.toptal.com\/developers\/sorting-algorithms\" rel=\"noopener noreferrer nofollow\">Sorting Algorithms Animations<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.cs.usfca.edu\/~galles\/visualization\/Heap.html\" rel=\"noopener noreferrer nofollow\">Min Heap sort<\/a><\/p>\n<\/li>\n<\/ol>\n<h3>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h3>\n<ol>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/335920\/\" rel=\"noopener noreferrer nofollow\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/academy.yandex.ru\/posts\/osnovnye-vidy-sortirovok-i-primery-ikh-realizatsii\" rel=\"noopener noreferrer nofollow\">\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043e\u043a \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/a><\/p>\n<\/li>\n<\/ol>\n<h3>\u0412\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0430\u0442<\/h3>\n<ol>\n<li>\n<p><a href=\"https:\/\/vovenur.medium.com\/numpy-sorting-and-dancing-and-memes-bf3ce0fe7c3\" rel=\"noopener noreferrer nofollow\">NumPy sorting (and dancing and memes)<\/a>&nbsp;(Medium)<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.slideshare.net\/VladimirFadeev4\/numpy-sorting-and-dancing-and-memes-a-short-review-for-students\" rel=\"noopener noreferrer nofollow\">NumPy sorting (and dancing and memes): \u200b a short review for students<\/a>\u200b (SlideShare)<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/568482\/\"> https:\/\/habr.com\/ru\/post\/568482\/<\/a><br \/><\/br><\/br><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-326658","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=326658"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326658\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}