I have a list of objects, these objects are actually chess pieces.

Each object contains the name of the price and it position on the chess table.
Names are `K` for king, `Q` for queen, `R` for rook... and so on.

So I have an `ArrayList<Enemy> chesspieces`. The list is not sorted, elements might be something like this: 

```
P,P,P,P,P,P,P,P,R,N,B,Q,K,B,N,R.

```

I would like to create some sort of a prioritySort, to have a list like this:

```
K,Q, R, R, B, B, N,N,R,R P,P,P,P,P,P,P,P

```

I started doing something, but I see how it's flawed and I am not sure how to implement that, here is what I did so far

here is my updated Enemy class

```

public class Enemy implements Comparable {

        public Piece name;
        public int rank;
        public int file;
        public String position;
        private int value;

        public Enemy(Piece name, int file, int rank,  String position) {
            this.name = name;
            this.rank = rank;
            this.file = file;
            this.position = position;
        }

    public int getValue(Piece name) {
        if (name.toString() == "k") value = 0;
        if (name.toString() == "Q") value = 1;
        if (name.toString() == "R") value = 2;
        if (name.toString() == "B") value = 3;
        if (name.toString() == "N") value = 4;
        if (name.toString() == "R") value = 5;
        if (name.toString() == "P") value = 6;
        System.out.println("ENMIY : " + name.toString() + " threat" + value);
        return value;
    }

    @Override
    public int compareTo(Object o) {
        if (o instanceof Enemy) {
            Enemy other = (Enemy)o;

            return this.value - other.value;
        } else {
            return 0;
        }
    }
}

```

here is my output

```
Collections.sort(enemyLocation);// PPNPPPPPPRNBQKBR

```