function Main(input) {
  var inputs = input.split("\n");
  var s = inputs[0].split("").sort().join();
  var t = inputs[1].split("").sort().reverse().join();

  console.log(s < t ? "Yes":"No");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));