Can you write a Python program that takes a list of strings as an argument and returns the list with all elements sorted by their length?
['Cat','Dog','Elephant','Horse']
def sort_by_length(strings):
    return sorted(strings, key=len)