I have a float array and a String array. each float value match with a specific String. I would like to sort the float array keeping the own string using :
I solved merging both answare:
public class VoiceRecognitionDemo extends Activity implements Comparator() {
@Override
public int compare(ResultVoiceObject arg0, ResultVoiceObject arg1) {
return Float.compare(arg0.getRanking(), arg1.getRanking());
}
});
}
public int compare(ResultVoiceObject lhs, ResultVoiceObject rhs) {
// TODO Auto-generated method stub
return 0;
}
}
Where:
public class ResultVoiceObject
{
private String frase;
private float ranking;
public ResultVoiceObject(String f, float r)
{
this.frase=f;
this.ranking= r;
}
}
Another way is:
ADD
import java.util.Arrays;
import java.util.Comparator;
REMOVE: implements Comparator and the compare methos out onActivityResult
Thanks stackoverflow comunity!