Files

21 lines
738 B
Python

# HumanEval/86
# Loki Mode Multi-Agent Solution
# Attempts: 1
# Passed: True
def anti_shuffle(s):
"""
Write a function that takes a string and returns an ordered version of it.
Ordered version of string, is a string where all words (separated by space)
are replaced by a new word where all the characters arranged in
ascending order based on ascii value.
Note: You should keep the order of words and blank spaces in the sentence.
For example:
anti_shuffle('Hi') returns 'Hi'
anti_shuffle('hello') returns 'ehllo'
anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
"""
words = s.split(' ')
sorted_words = [''.join(sorted(word)) for word in words]
return ' '.join(sorted_words)