Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

sorting

How to use a custom comparison function in Python 3?

August 16, 2022 by Magenaut

In Python 2.x, I could pass custom function to sorted and .sort functions

Categories Python, Q&A Tags python, python-3.x, sorting Leave a comment

How to sort and remove duplicates from Python list?

August 16, 2022 by Magenaut

Given a list of strings, I want to sort it alphabetically and remove duplicates. I know I can do this: from sets import Set […] myHash = Set(myList) but I don’t know how to retrieve the list members from the hash in alphabetical order. I’m not married to the hash, so any way to accomplish … Read more

Categories Python, Q&A Tags list, python, sorting, unique Leave a comment

case-insensitive list sorting, without lowercasing the result?

August 16, 2022 by Magenaut

I have a list of strings like this:

Categories Python, Q&A Tags case-insensitive, list, python, sorting, string Leave a comment

How can I get 2.x-like sorting behaviour in Python 3.x?

August 16, 2022 by Magenaut

I’m trying to replicate (and if possible improve on) Python 2.x’s sorting behaviour in 3.x, so that mutually orderable types like int, float etc. are sorted as expected, and mutually unorderable types are grouped within the output.

Categories Python, Q&A Tags python, python-2.x, python-3.x, sorting Leave a comment

Sorting a 2D numpy array by multiple axes

August 16, 2022 by Magenaut

I have a 2D numpy array of shape (N,2) which is holding N points (x and y coordinates). For example:

Categories Python, Q&A Tags numpy, python, sorting Leave a comment

Sort a pandas dataframe series by month name

August 16, 2022 by Magenaut

I have a Series object that has:

Categories Python, Q&A Tags dataframe, date, pandas, python, sorting Leave a comment

How can I “zip sort” parallel numpy arrays?

August 16, 2022 by Magenaut

If I have two parallel lists and want to sort them by the order of the elements in the first, it’s very easy:

Categories Python, Q&A Tags numpy, python, sorting Leave a comment

Python: sort function breaks in the presence of nan

August 16, 2022 by Magenaut

sorted([2, float('nan'), 1]) returns [2, nan, 1]

Categories Python, Q&A Tags math, nan, python, sorting Leave a comment

Accessing the list while being sorted

August 16, 2022 by Magenaut

Can I access a list while it is being sorted in the list.sort()

Categories Python, Q&A Tags list, python, python-internals, sorting Leave a comment

Python sorting by multiple criteria

August 15, 2022 by Magenaut

I have a list where each element is of the form

.
For example, an element of the list may look like this [[1,3,1,2], -1].

Categories Python, Q&A Tags python, sorting Leave a comment
Older posts
Newer posts
← Previous Page1 … Page6 Page7 Page8 … Page10 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress