You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
import sys

def main():
  s = list(input())
  t = list(input())
  
  s.sort()
  t.sort()
  m = min(len(s), len(t))
  for i in range(m):
    if s[i] == t[i]:
      pass
    elif s[i] > t[i]:
      print('No')
      sys.exit()
    elif s[i] < t[i]:
      print('Yes')
      sys.exit()
  if len(s) == len(t):
    print('No')
    sys.exit()
  if len(s) < len(t):
    print('Yes')
    sys.exit()
  else:
    print('No')
    sys.exit()
    
main()
import sys

def main():
  s = list(input())
  t = list(input())
  
  s.sort()
  t.sort()
  t.reverse()
  m = min(len(s), len(t))
  for i in range(m):
    if s[i] > t[i]:
      print('No')
      sys.exit()
    elif s[i] < t[i]:
      print('Yes')
      sys.exit()

  if len(s) < len(t):
    print('Yes')
    sys.exit()
  else:
    print('No')
    sys.exit()
    
main()
