def longest_substring(string):
    curr, subs = '', ''
for char in string:
    if not curr or char >= curr[-1]:
        curr += char
else:
    curr, subs = '', max(curr, subs, key=len)
return max(curr, subs, key=len)
Find the longest substring in alphabetical order