Ask coding questions

← Back to all posts
How to sort an iterable in python whilst keeping duplicate values
Dunce

This code:

outputs: [1, 2, 3]
But I would like it to keep the duplicate values, that is to say it should output something more like this: [1, 1, 1, 2, 2, 2, 3, 3, 3]
How would I do that?

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Dunce
Comments
hotnewtop
Coder100
Dunce

@Coder100 Turns out some other issue is causing the duplicate values to be deleted. Thanks though!

Coder100

oh
Well np @Dunce