Skip to content

Commit

Permalink
[Feature #14] Change sort method
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew-Kulich committed Mar 2, 2022
1 parent f9e5c21 commit 5a90e43
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,23 +423,13 @@ protected ExecutionContext createOutputContext(boolean isReplace, Model inputMod

private List<Resource> sortConstraintQueries(List<Resource> constraintQueries) {
return constraintQueries.stream().sorted((resource1, resource2) -> {

org.topbraid.spin.model.Query spinQuery1 = SPINFactory.asQuery(resource1);
org.topbraid.spin.model.Query spinQuery2 = SPINFactory.asQuery(resource2);

String comment1 = spinQuery1.toString().split("\\n")[0];
String comment2 = spinQuery2.toString().split("\\n")[0];

if (comment1.matches("\\s*#.*") && comment2.matches("\\s*#.*")) {
int mainNumber1 = Integer.parseInt(comment1.split(" ")[1].split("\\.")[0]);
int mainNumber2 = Integer.parseInt(comment2.split(" ")[1].split("\\.")[0]);

int minorNumber1 = Integer.parseInt(comment1.split(" ")[1].split("\\.")[1]);
int minorNumber2 = Integer.parseInt(comment2.split(" ")[1].split("\\.")[1]);

return mainNumber1 < mainNumber2 ? -1 : (mainNumber1 > mainNumber2 ? 1 : (minorNumber1 <= minorNumber2) ? -1 : 1);
}
return 0;
return comment1.compareTo(comment2);
}).collect(Collectors.toList());
}

Expand Down

0 comments on commit 5a90e43

Please sign in to comment.