1// Copyright 2015 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5package strings 6 7import "internal/bytealg" 8 9// Compare returns an integer comparing two strings lexicographically. 10// The result will be 0 if a == b, -1 if a < b, and +1 if a > b. 11// 12// Use Compare when you need to perform a three-way comparison (with 13// [slices.SortFunc], for example). It is usually clearer and always faster 14// to use the built-in string comparison operators ==, <, >, and so on. 15func Compare(a, b string) int { 16 return bytealg.CompareString(a, b) 17} 18