int i = Collections.binarySearch(data,row, new Compare());
int i = Collections.binarySearch(data,row, new CompareSearch());
    public ArrayList<TableRow> search(ArrayList<TableRow> data, String filter){                ArrayList<TableRow> result = new ArrayList<TableRow>();        TableRow row = new TableRow();        row.setLang1(filter+"%");        boolean found = false;                while (!found){            int i = Collections.binarySearch(data,row, new Compare());                        if (i>=0){                found = true;                int start = i;                                //Search before                for (int h = start; h >= 0; h--){                    TableRow tmp = data.get(h);                    String value = tmp.getLang1();                    int reduction = filter.length() < value.length() ? filter.length() : value.length();                    if (!filter.equalsIgnoreCase(value.substring(0,reduction)))                        break;                    result.add(tmp);                }                //reverse collected result                Collections.reverse(result);                //Search after                for (int h = start+1; h < data.size(); h++){                    TableRow tmp = data.get(h);                    String value = tmp.getLang1();                    int reduction = filter.length() < value.length() ? filter.length() : value.length();                    if (!filter.equalsIgnoreCase(value.substring(0,reduction)))                        break;                    result.add(tmp);                }            }                        if (!found) {                if (filter.length()>0){                     filter = filter.substring(0, filter.length()-1);                     row.setLang1(filter+"%");                }else                   found = true;            }        }        return result;    }