Skip to content

Commit d9b1d25

Browse files
committed
Revert "sort-by-multiple-fields (#213)"
This reverts commit aa0f654.
1 parent aa0f654 commit d9b1d25

File tree

1 file changed

+2
-23
lines changed
  • src/main/java/com/github/hcsp/polymorphism

1 file changed

+2
-23
lines changed

src/main/java/com/github/hcsp/polymorphism/Point.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
import java.io.IOException;
44
import java.util.Arrays;
5-
import java.util.Collections;
65
import java.util.List;
76

8-
public class Point implements Comparable<Point>{
7+
public class Point {
98

109
private final int x;
1110
private final int y;
12-
1311
// 代表笛卡尔坐标系中的一个点
1412
public Point(int x, int y) {
1513
this.x = x;
@@ -55,10 +53,7 @@ public String toString() {
5553

5654
// 按照先x再y,从小到大的顺序排序
5755
// 例如排序后的结果应该是 (-1, 1) (1, -1) (2, -1) (2, 0) (2, 1)
58-
public static List<Point> sort(List<Point> points) {
59-
Collections.sort(points);
60-
return points;
61-
}
56+
public static List<Point> sort(List<Point> points) {}
6257

6358
public static void main(String[] args) throws IOException {
6459
List<Point> points =
@@ -70,20 +65,4 @@ public static void main(String[] args) throws IOException {
7065
new Point(2, -1));
7166
System.out.println(Point.sort(points));
7267
}
73-
74-
@Override
75-
public int compareTo(Point that) {
76-
if (this.x < that.x) {
77-
return -1;
78-
} else if (this.x > that.x) {
79-
return 1;
80-
}
81-
if (this.y < that.y) {
82-
return -1;
83-
} else if (this.y > that.y) {
84-
return 1;
85-
}
86-
return 0;
87-
88-
}
8968
}

0 commit comments

Comments
 (0)