DEV Community

Discussion on: Beware of PHP’s strcmp() function when sorting

Collapse
 
lyrixx profile image
Grégoire Pineau • Edited

Hello,

Why don't you use strnatcmp: php.net/manual/en/function.strnatc... ?
or directly <=> operator?

Collapse
 
wnbsmart profile image
Maroje Macola

Sorry for the late response, thanks for your comment!
You are right, spaceship is a great choice for this case, and it's mentioned in the referenced SO from the intro of the post.

But, take a look at the conclusion from the post - "Copy-pasting solutions from Stack Overflow without enough research can result in big damage." Hope this answers your question :)