open Batteries

let solve s t =
  let ss = String.to_list s |> List.sort compare |> String.of_list in
  let st = String.to_list t |> List.sort (fun a b -> compare b a) |> String.of_list in
  let sorted = List.sort compare [ss; st] in
  let answer = (ss <> st) && (List.hd sorted = ss) in
  print_string @@ if answer then "Yes" else "No" 

let () = Scanf.scanf "%s\n%s" solve 