Maintaining Order: Unique and Sorted List Function

  • Share this:

Code introduction


The function takes a list as input, first removes duplicates using set, then sorts the result with the sorted function while maintaining the original order of elements in the list.


Technology Stack : Built-in libraries - list, set, sorted

Code Type : Function

Code Difficulty : Intermediate


                
                    
def sorted_unique_list(input_list):
    return sorted(set(input_list), key=input_list.index)