← Docs
kotlin-stdlib / kotlin.text / compareTo

compareTo

Common
JVM
JS
Native
1.0
fun String . compareTo (
other : String ,
ignoreCase : Boolean = false
) : Int

(Common source) (JVM source) (JS source) (Native source)

Compares two strings lexicographically, optionally ignoring case differences.

If ignoreCase is true, the result of Char.uppercaseChar().lowercaseChar() on each character is compared.

Stay in touch:
  • Contributing to Kotlin
  • Releases
  • Press Kit
  • Security
  • Blog
  • Issue Tracker
  • Brand assets
  • Careers
Supported and developed by JetBrains .
Kotlin™ is protected under the Kotlin Foundation
and licensed under the Apache 2 license .