Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Sorting a deque in Python

$
0
0
So I have a deque of people objects. A person contains a name and an age, that's it. I'm trying to figure out how to sort the deque on the name field.

p1 = person("Tom", 31)
p2 = person("Jason", 33)
p3 = person("Adam", 23)
p4 = person("Megan", 28)


classroom = deque()
classroom.append(p1)
classroom.append(p2)
classroom.append(p3)
classroom.append(p4)

#deque is now full of unsorted people



Any idea how to sort, just based on the name field?

Viewing all articles
Browse latest Browse all 51036

Latest Images

Trending Articles



Latest Images