Given embeddings, perform an index sort (ascending and descending) and write the code in Notepad, then optimize the approach.
Asked in the VP Technical Interview stage. Focus was on DSA fundamentals, hash maps/hashing, and optimization thinking.
Implement a function that takes a list of numeric embedding scores and returns the indices that would sort the list in ascending order and in descending order.
sort_embedding_indices(embeddings)
embeddings: a list of integers or floatsascending: indices sorted by embedding value from smallest to largestdescending: indices sorted by embedding value from largest to smallestIf two values are equal, preserve their original relative order in both outputs.
def sort_embedding_indices(embeddings):