Linked Questions

0 votes
0 answers
26 views

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): ...
bytepusher's user avatar
  • 1,578
1 vote
1 answer
3k views

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 = ...
XenoChrist's user avatar
-1 votes
2 answers
2k views

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 ...
Kapil G's user avatar
  • 17
0 votes
2 answers
563 views

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 ...
Ruan's user avatar
  • 942
0 votes
1 answer
291 views

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 ...
Myth's user avatar
  • 51
0 votes
4 answers
171 views

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 ...
Julien's user avatar
  • 629
0 votes
0 answers
129 views

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, ...
vlovero's user avatar
  • 300
0 votes
0 answers
123 views

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/...
CodeDezk's user avatar
  • 1,278
-3 votes
1 answer
67 views

biglist = [['Bob', 10], ['Karl', 12], ['Judy', 11]] customsort(biglist) Should return this: biglist = [['Bob', 10], ['Judy', 11], ['Karl', 12]]
Marek Tran's user avatar
-3 votes
2 answers
83 views

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&...
bwanaHA's user avatar