Linked Questions
10 questions linked to/from Sort a list of lists with a custom compare function
0
votes
0
answers
26
views
Sorting a list in python relative to elements [duplicate]
I would like to sort a list by referring to the elements being compared. So if one element has attribute X to other element, I want it first.
Simple example:
class Apple:
def can_eat(self, other):
...
1
vote
1
answer
3k
views
Sort django queryset using a Python list
I have a
Model Car(self.Models)
# a bunch of features here
then in my views.py, I get all the cars and compute a score for them:
allCars = Car.object.all() # so you get [A, B, C, D]
scoreList = ...
-1
votes
2
answers
2k
views
How to apply sorting algorithms on a dictionary?
I have a dictionary d as:
d = {3: 'a', 5: 'g', 1: 't', 4: 'y'}
I want to sort it so the result is:
d = {1: 't', 3: 'a', 4: 'y', 5: 'g'}
To get that result, I need to apply a sorting algorithm on the ...
0
votes
2
answers
563
views
Sort numpy array according to a boolean square matrix
Suppose a numpy array A with shape (n,), and a boolean numpy matrix B with shape (n,n).
If B[i][j] is True, then A[i] should be sorted to a position before A[j].
If B[i][j] is False, then A[i] should ...
0
votes
1
answer
291
views
leaderboard Command Discord.py rewrite with JSON
I was trying to make a leaderboard command for my level system on discord.py with JSON but for some weird reason, it won't work. Only the top 3 highest level players are shown instead of the top 5 and ...
0
votes
4
answers
171
views
How to optimize the sorting of a big table with Python
I have a table A with all values hidden.
The goal is to find a trick to sort these values with the help of two functions :
compare (x, y) checks in the table A whether x value < y value or not
If ...
0
votes
0
answers
129
views
Sorting tuples in alphabetical order without built-in sort
If I have a list of tuples that such as names = [('first1,last1'), ('first2,last2'),...]
I know I can sort them alphabetically with the built-in sort by simply doing
sorted_names = sorted(names, ...
0
votes
0
answers
123
views
python sort file path based on created time [duplicate]
I have python array with filepath in it, I need to sort the files path based on created date. Is there any inbuilt functionality exist for it.
files = ["/path1/filename.text", "/path2/...
-3
votes
1
answer
67
views
How to sort list of lists by an integer in the lists inside [duplicate]
biglist = [['Bob', 10], ['Karl', 12], ['Judy', 11]]
customsort(biglist)
Should return this:
biglist = [['Bob', 10], ['Judy', 11], ['Karl', 12]]
-3
votes
2
answers
83
views
Python 3 - How to sort list of dictionaries with keys, using certain field in dict [duplicate]
Hi This might sounds confusing, but I will try to explain best I can.
My list of dictionaries looks like this:
{
"1": {
"bd_date": "04/02/1977",
"name&...