v1.9.10
  • Solutions
    • Multiplatform
    • Server-side
    • Data science
    • Android
  • Docs
  • Community
  • Teach
  • Play
    • Playground
    • Examples
    • Koans
← 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
Kotlin™ is protected under the Kotlin Foundation and licensed under the Apache 2 license.
Supported and developed by JetBrains