I am writing a program to sort a list fo input strings (song names).
Those songnames contains latex chars like $\\lambda$, which i want to
get sorted like \'lambda\' instead, s
There is nothing wrong with the code: what you're experiencing is repr behaviour. Printing a list causes it's contents to be repr'd, and repr escapes \.
print repr(r'\foo') # => '\\foo'
If you want to print the list without repr, you use either a loop or str.join.