// Arup Guha
// 10/16/2026
// Solution to COP 3330 Exam #2 Question #8

import java.util.*;

public class Coordinate implements Comparable<Coordinate> {

    private char row;
    private int  col;

    public Coordinate(char r, int c) {
        row = r;
        col = c;
    }

    public int compareTo(Coordinate other) {

		// First look at rows, if unequal answer based on that.
		if (this.row != other.row)
			return this.row - other.row;
		
		// Only ties go to column.
		return this.col - other.col;
    }
	
	public String toString() {
		return ""+row+col;
	}
	
	/*** Run some tests. ***/
	public static void main(String[] args) {
		Coordinate[] list = new Coordinate[5];
		list[0] = new Coordinate('D',12);
		list[1] = new Coordinate('C', 20);
		list[2] = new Coordinate('A', 2);
		list[3] = new Coordinate('C', 16);
		list[4] = new Coordinate('B', 7);	
		for (Coordinate c: list) System.out.println(c);
		System.out.println();
		Arrays.sort(list);
		for (Coordinate c: list) System.out.println(c);
		System.out.println();
	}
}
