"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("").sort();
    const T = arg[1].split("").sort().reverse();

    console.log(T > S ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));