Product SiteDocumentation Site

5.4.25.10. compareTo


>>-compareTo(other)--------------------------------------------><

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.206. Class FILE - conpareTo method


file1 = .File~new("file", "dir")
file2 = .File~new("FILE", "DIR")
'cd' .File~listRoots[1]
file1~compareTo(file2)    -- 0 on Windows (both Files denote the same path)
file1~compareTo(file2)    -- 1 on Unix ("/dir/file" is greater than "/DIR/FILE")