
function Main(input) {
    var S = input[0];
    var T = input[1];
    
    var sList = [];
    var tList = [];
    
    for (var s of S) {
        sList.push(s);
    }
    
    for (var t of T) {
        tList.push(t);
    }
    sList = sList.sort((a, b) => a > b ? 1 : -1);
    tList = tList.sort((a, b) => a > b ? -1 : 1);
    // console.log(sList);
    // console.log(tList);
    console.log(sList < tList ? 'Yes' : 'No');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));