You will be given a vector of string(s). You must sort it alphabetically (case-sensitive!!) and then return the first value.

The returned value must be a string and have “***” between each of its letters.

You should not remove or add elements from/to the array.

Above is another problem in codewars, besides asking us to sort the array list and returning the first value in that list, we also need to insert stars within the characters.

```def two_sort(array):

array.sort()
first_string = array
first_star_string = ''
limit = len(first_string)

for i in range(0, limit):
if i == 0:
first_star_string += first_string[i]
else:
first_star_string +='***'+first_string[i]

return first_star_string
```

The python solution above is straight forward but needs further improvement if possible, do write down your own answer in the comment box below this post.

1. Walter Dörwald says:

Much simpler:

>>> def two_sort(array):
… array.sort()
… return ‘***’.join(array)

>>> two_sort([‘foo’, ‘bar’, ‘baz’])
‘b***a***r’

And even simpler:

>>> def two_sort(array):
… return ‘***’.join(min(array))

(if the array doesn’t need to be sorted)

2. Ingmar says:

To insert the ‘***’ between each character, you can use `’***’.join(first_string)`. Also, I prefer not mutating the original input array:

“`
def two_sort(array):
first_string = sorted(array)
return ‘***’.join(first_string)
“`

3. Mike says:

Unless we want array to be sorted after calling the function (as a side effect) then all we need is the first string alphabetically, with its characters separated by ‘***’:

“`
def two_sort(array):
‘***’.join(min(array))
“`

4. Walter Doerwald says:

If you don’t want to mutate the array, you don’t even have to sort it since you’re only interested in the first string in sorted order anyway, which can be done with min(array) instead of sorted(array)