1 package com.github.mikephil.charting.utils; 2 3 import com.github.mikephil.charting.data.Entry; 4 5 import java.util.Comparator; 6 7 /** 8 * Comparator for comparing Entry-objects by their x-value. 9 * Created by philipp on 17/06/15. 10 */ 11 public class EntryXComparator implements Comparator<Entry> { 12 @Override compare(Entry entry1, Entry entry2)13 public int compare(Entry entry1, Entry entry2) { 14 float diff = entry1.getX() - entry2.getX(); 15 16 if (diff == 0f) return 0; 17 else { 18 if (diff > 0f) return 1; 19 else return -1; 20 } 21 } 22 } 23