import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val t = sc.next()
    var sA = Array(s.length) { ' ' }
    var tA = Array(t.length) { ' ' }
    for (i in 0 until s.length) {
        sA[i] = s[i]
    }
    for (j in 0 until t.length) {
        tA[j] = t[j]
    }

    (if (judge(calc(sA), calc(tA).reversedArray())) "Yes" else "No")
            .let(::println)
}

fun calc(s: Array<Char>): Array<Char> {
    return s.sortedArray()
}

fun judge(s: Array<Char>, t: Array<Char>): Boolean {
    for (i in 0 until Math.max(s.size, t.size)) {
        if (i >= s.size) {
            return true
        }
        if (i >= t.size) {
            return false
        }
        if (s[i] < t[i]) {
            return true
        }
        if (s[i] > t[i]) {
            return false
        }
    }
    return false
}
