package com.example.Vezba.model;

import java.util.Comparator;

import static java.lang.Float.parseFloat;

public class SortByOcena implements Comparator<Korisnik> {
    // Used for sorting in ascending order of ID
    public int compare(Korisnik a, Korisnik b) {

        if(a.getOcena().equals("Neocenjen ") && b.getOcena().equals("Neocenjen "))
            return 0;


        if(a.getOcena().equals("Neocenjen "))
            return 1;


        if(b.getOcena().equals("Neocenjen "))
            return -1;

        return ((int) (parseFloat(b.getOcena())*100) - (int)(parseFloat(a.getOcena())*100));
    }
}