RosettaCodeData/Task/String-comparison/Lingo/string-comparison-2.lingo

11 lines
318 B
Plaintext

-- Returns -1 if str1 is less than str2
-- Returns 1 if str1 is greater than str2
-- Returns 0 if str1 and str2 are equal
on strcmp (str1, str2)
h1 = bytearray(str1).toHexString(1, str1.length)
h2 = bytearray(str2).toHexString(1, str2.length)
if h1<h2 then return -1
else if h1>h2 then return 1
return 0
end