FAQ: Code Challenge: Lists - Combine Sort


#1

This community-built FAQ covers the “Combine Sort” exercise from the lesson “Code Challenge: Lists”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science
Data Science

FAQs on the exercise Combine Sort

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


#2


This is the solution and I am still receiving syntax errors. You have to change 1st, 1st1, or 1st2 to first, first1, or first2 to get it to work. The instructions need to be changed or the exercise needs to be fixed.


#3

I think your first function parameter is typed “1st1” instead of “lst1”. Easy mistake to make.


#4

so i know the solution provided is to use:

def combine_sort(lst1, lst2):
unsorted = lst1 + lst2
sortedList = sorted(unsorted)
return sortedList

but would using .sort() be better? When should I used .sort() instead of sorted()?
i used .sort() first before i checked the solution

def combine_sort(lst1, lst2):
new_list = (lst1 + lst2)
new_list.sort()
return new_list


#5

Well, what do they do differently, and which of those behaviours do you prefer?
It’s not so much a matter of which you should use, but rather finding out what they do and picking one that suits you.

Not sure what the point of the function/exercise is though… the caller can just as well concatenate and sort themselves