object Main extends App{
val s = scala.io.StdIn.readLine.toList
val t = scala.io.StdIn.readLine.toList

if (s.sorted.foldLeft("")(_ + _) < t.sorted.reverse.foldLeft("")(_ + _) ){
  println("Yes")
} else{
  println("No")
}
}