Question: In Android, I'd like to print fast changing text (>10 Hz) on the smartphone screen instead of into the log file. How should I change the following code?

```
public void onSensorChanged(SensorEvent event) { 
    System.out.println(event.values[0] );  
}

```

Answer: 
You are missing a bit the definition of the of your method:

```
public static <T, U extends Comparable<? super U>> void sortEmpoyeeByCriteria(Function<? super T, ? extends U> byCriteria) {
        Comparator<T> c = Comparator.comparing(byCriteria);
}

```

You should also pass the `List` to that method that you want to sort in this case.

But then why not use `Collections.sort` in this case and pass the `List` and the `Comparator` in the form (for example):

```
Collections.sort(yourList, Comparator.comparing(Employee::getXXX))

```

**EDIT**
You could declare it like this:

```
public static <T, U extends Comparable<? super U>> void sortEmpoyeeByCriteria(
            List<T> list,
            Function<? super T, ? extends U> byCriteria) {
        Comparator<? super T> c = Comparator.comparing(byCriteria);
        list.sort(c);
}

```
You can use a reference method

```
public static void main(String[] args) {
    Employee[] employees = new Employee[] { new Employee("John", 25, 3000.0, 9922001),
            new Employee("Ace", 22, 2000.0, 5924001), new Employee("Keith", 35, 4000.0, 3924401) };

    Comparator<Employee> comparingAge = Comparator.comparing(Employee::getAge);
    Comparator<Employee> comparingName = Comparator.comparing(Employee::getName);
    Comparator<Employee> comparingSalary = Comparator.comparing(Employee::getSalary);

    Arrays.sort(employees, comparingAge);
    System.out.println(Arrays.toString(employees));

    Arrays.sort(employees, comparingName);
    System.out.println(Arrays.toString(employees));

    Arrays.sort(employees, comparingSalary);
    System.out.println(Arrays.toString(employees));
}

```

---

you can do too:

```
    sortMe(employees, comparingAge);
    sortMe(employees, comparingName);
    sortMe(employees, comparingSalary);

```

where sortme is :

```
private static void sortMe(Employee[] employees, Comparator<Employee> comparingCriteria) {
    Arrays.sort(employees, comparingCriteria);
}

```