changed sort and comparator to recive a list of Range intead of dirs