/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone
{
public Ideone(){
ArrayList<Funcionario> funcionarios = new ArrayList<>();
funcionarios.add(new Funcionario("João"));
funcionarios.add(new Funcionario("Bruno"));
funcionarios.add(new Funcionario("Kleosvaldo"));
funcionarios.add(new Funcionario("Wellington"));
System.
out.
println("Antes: "); funcionarios.stream().forEach((funcionario) -> {
System.
out.
println(funcionario.
getNome()); });
Collections.
sort(funcionarios,
new FuncionarioComparator
());
System.
out.
println("Depois: "); funcionarios.stream().forEach((funcionario) -> {
System.
out.
println(funcionario.
getNome()); });
}
{
new Ideone();
}
class FuncionarioComparator implements Comparator<Funcionario> {
@Override
public int compare(Funcionario funcionario1, Funcionario funcionario2) {
return funcionario1.getNome().compareTo(funcionario2.getNome());
}
}
class Funcionario {
public Funcionario
(String nome
) { this.nome = nome;
}
return nome;
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgoKY2xhc3MgSWRlb25lCnsKCQoJcHVibGljIElkZW9uZSgpewoJCUFycmF5TGlzdDxGdW5jaW9uYXJpbz4gZnVuY2lvbmFyaW9zID0gbmV3IEFycmF5TGlzdDw+KCk7CiAgICAgICAgZnVuY2lvbmFyaW9zLmFkZChuZXcgRnVuY2lvbmFyaW8oIkpvw6NvIikpOwogICAgICAgIGZ1bmNpb25hcmlvcy5hZGQobmV3IEZ1bmNpb25hcmlvKCJCcnVubyIpKTsKICAgICAgICBmdW5jaW9uYXJpb3MuYWRkKG5ldyBGdW5jaW9uYXJpbygiS2xlb3N2YWxkbyIpKTsKICAgICAgICBmdW5jaW9uYXJpb3MuYWRkKG5ldyBGdW5jaW9uYXJpbygiV2VsbGluZ3RvbiIpKTsKICAgICAgICAKICAgICAgICBTeXN0ZW0ub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