var lines = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

var s = lines[0].split("");
var t = lines[1].split("");

var compareFunc = (a, b) => {
  return (b>a?1:-1);
};

s = s.sort();
t = t.sort(compareFunc);

s = s.join("")
t = t.join("")

if(s < t){
  console.log("Yes")
}else{
  console.log("No")
}