strcoll(3)
๐ strcoll(3) โ the man page bestie edition ๐
okay so real talk, this is strcoll from the Library Functions Manual, and if you've ever sorted a list and gotten vibes-based order that doesn't match your alphabet, this function is why. let's get into it ๐ฆ
โจ NAME โจ
strcoll โ strings LC_COLLATE compare
like, it literally compares strings, but culturally. it's giving "I know what order your language actually wants" ๐
๐ LIBRARY ๐
Standard C library (libc, -lc)
so you already have it, bestie. no extra install. periodt.
๐ธ SYNOPSIS ๐ธ
#include <string.h>
int strcoll(const char *s1, const char *s2);
two strings walk in, one int walks out. iconic behaviour honestly.
๐ DESCRIPTION ๐
The strcoll() function compares the two strings s1 and s2. It returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2.
here's the tea though: the comparison is based on strings interpreted as appropriate for the program's current locale for category LC_COLLATE. so it's not comparing raw byte values like some feral gremlin โ it's asking "in this locale, what order do these actually go in?" ๐ง
(peep setlocale(3) for how you set that locale in the first place.)
๐ซ RETURN VALUE ๐ซ
The strcoll() function returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2, when both are interpreted as appropriate for the current locale.
so like:
< 0โs1comes first, no cap0โ they're the same, twin behaviour> 0โs1comes after, sorry babes
๐ ATTRIBUTES ๐
for an explanation of the terms used in this section, go see attributes(7). here's the rundown:
- Interface:
strcoll() - Attribute: Thread safety
- Value:
MT-Safe locale
translation? it's thread safe but the locale part matters โ locale is shared state, so don't be chaotic about switching it mid-flight ๐
๐ STANDARDS ๐
C11, POSIX.1-2008.
it's been standardised for AGES. certified, not a random hack. โ
๐ HISTORY ๐
POSIX.1-2001, C89, SVr4, 4.3BSD.
this function is old enough to have lore. it was doing locale-aware sorting before it was cool ๐ฅ
๐ NOTES ๐
In the POSIX or C locales, strcoll() is equivalent to strcmp(3).
yep โ in those locales there's no fancy collation going on, so it's basically just strcmp wearing a little costume. cute but true ๐
๐ซถ SEE ALSO ๐ซถ
and that's the whole page bestie!! ๐ this was Linux man-pages 6.20, dated 2026-08-10 โ go forth and sort your strings the culturally correct way. slay, stay locale-aware, and don't forget to setlocale(3) first or you're gonna have a bad time ๐ญโจ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms