Sort without duplicates X13743


Statement
 

pdf   zip

thehtml

Write a function sort_no_dup that receives a list of integers, possibly including repeated entries, and returns a sorted list with the same integers without any repetition.

Input The function receives a list of integers as a parameter.

Output The function returns as a result a list of integers sorted and without duplicate elements.

Observation You are allowed to use any predefined Python function or data structure you deem appropriate.

You only need to provide the function. Remember not to include doctest calls or any other main program in your submission.

Sample session
>>> sort_no_dup([5, 1, 5, 2, 4, 1, 4, 8, 2, 1])
[1, 2, 4, 5, 8]
>>> sort_no_dup([])
[]
>>> sort_no_dup([33, 33, 33, 33, 33, 33])
[33]
>>> sort_no_dup([7, 6, 7, 6, 7, 6])
[6, 7]
>>> sort_no_dup([258, 256, 254, 252, 250])
[250, 252, 254, 256, 258]
Information
Author
Language
English
Official solutions
Python
User solutions
Python