Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialHank Boudreau
804 PointsHow to sort by descending, regardless of special characters?
I was in the first practice question and was just messing around to test my knowledge. I wanted to combine the names of actors and the number of letters in their name and wrote this query. Finally I wanted to sort them in descending order.
select name || " (amount of letters) " || length (name) as "Name + Letter #" from actors
order by name desc
When it returned the results I was expecting a name that started with a Z. What I got was Íñigo Garcés followed by Édgar Ramírez, etc. I don't understand the programming behind SQL databases but clearly, letters with characters are "lower" than Z in the alphabet. So I'm wondering how would I get these names in the right place, regardless of their characters? Eg: Inigo would be next to someone named Indiana.
1 Answer
Steven Parker
231,261 PointsThis would typically be done by using the COLLATE function, but I'm not sure there's a predefined collation sequence in SQLite to fold international characters as you want (there is in other DB engines). You may need to do some research on defining custom collation sequences.