I can't find anything to help me out on this method of sorting. How do I do it?
chris99 0 Junior Poster
Recommended Answers
Jump to PostYou can, for fun, choose sort algorithm, use list of words (strings) and use len() for comparison...
http://www.daniweb.com/code/snippet452.html
Then, if you have problems making it work you can post code, so we can see what is wrong ;)
Jump to PostOh, one of Vegaseat's brain teasers. There are several ways to solve this. If you look in the Python reference manual under sort for lists, you find that you can specify your own custom sort method. In this case it would be sorting by length of each word/string in the …
Jump to PostThere are several ways to do this.
First use a for loop, word.lower() and list2.append(word) to create a new list2 from list1 with all lower case words.
Now you can convert list2 to a set with set1 = set(list2) which by design has only unique words. Convert this …
Jump to PostI think both Ene's and ghostdog74's solutions to the sort list by wordlength project are very clever! One could also use list comprehension for this.
Jump to PostEne, thanks for finding this old snippet. I knew I had done something like it. I hope our friend chris99 doesn't get too overwhelmed with the concept of list comprehensions. Actually the snippet at:
http://www.daniweb.com/code/snippet454.html
was written to explain list comprehensions. Using it for uniqueList is actually a special case …
All 18 Replies
Micko 2 Junior Poster
chris99 0 Junior Poster
Ene Uran 638 Posting Virtuoso
chris99 0 Junior Poster
Ene Uran 638 Posting Virtuoso
Ene Uran 638 Posting Virtuoso
chris99 0 Junior Poster
Ene Uran 638 Posting Virtuoso
chris99 0 Junior Poster
ghostdog74 57 Junior Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
Ene Uran 638 Posting Virtuoso
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
deeplavi 0 Newbie Poster
Taraka Rama 0 Newbie Poster
farmwife 0 Light Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
farmwife 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.