compareCodePoints

left against right by code point, the order in which every store compares text: PostgreSQL by COLLATE "C", MongoDB, Elasticsearch's keywords and ClickHouse by the bytes of their UTF-8, which order as the code points do. String.compareTo orders by UTF-16 code unit instead, which parts from it where a character above U+FFFF (an emoji, a CJK extension ideograph), stored as two surrogates (the code units 0xD800 to 0xDFFF), meets one of U+E000 to U+FFFF (the fullwidth forms, the compatibility ideographs, private use): A (U+FF21) is before 😀 (U+1F600) here.

One pass over the code units, as String.compareTo makes, with no allocation: at the first unit that differs, a surrogate is moved past U+E000 to U+FFFF (codePointRank), so the two compare as their code points would. A negative number, zero or a positive one, as a comparator answers.