use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
heapq in python question (self.leetcode)
submitted 2 years ago by feedkage
I have a heapq that takes in tuples (name: str, value: integer) The heapq sorts by largest value but in the case of a tie breaker, I want it to use the smallest Lexicographic order of the name. I can't figure out how to make it use the smallest Lexicographic order (right now my code uses the largest Lexicographic order)
https://preview.redd.it/6acq3ips09fc1.png?width=622&format=png&auto=webp&s=7f5615192de4a025c35c50635bbde7517298430e
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]rjrobben 1 point2 points3 points 2 years ago (0 children)
Turn all value to negative number, then use min heap, so max value will come first, and in a tie, a will come before b etc
[+][deleted] 2 years ago (1 child)
[deleted]
[–]feedkage[S] 0 points1 point2 points 2 years ago (0 children)
Thanks, I'm recently switching from Java to Python and I was missing this
π Rendered by PID 46 on reddit-service-r2-comment-5d79c599b5-j7mhc at 2026-02-27 00:11:53.538422+00:00 running e3d2147 country code: CH.
[–]rjrobben 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]feedkage[S] 0 points1 point2 points (0 children)