Product Site

5.4.8.15. compareTo

Performs a sorting comparison of the target File object to the other File object. The comparison is made on the absolute paths (strings) of both File objects. If the filesystem is case-sensitive then the paths comparison is case-sensitive, otherwise the comparison is caseless. If the two paths are equal, 0 is returned. If the target path is larger, 1 is returned. -1 if the other argument is the larger path.
Example 5.252. File class — compareTo method
call directory .File~listRoots[1]
file1 = .File~new("file", "dir")
file2 = .File~new("FILE", "DIR")
file1~compareTo(file2)  -- 0 on Windows (both Files denote the same path)
file1~compareTo(file2)  -- 1 on Unix-like system ("/dir/file" is greater than "/DIR/FILE")