public static List<Long> getUnique(List<Long> ids) {
    Long[] idsArray = ids.toArray(new Long[ids.size()]);
    Arrays.sort(idsArray);

    List<Long> uniqueList = new ArrayList<Long>();

    for (long id : idsArray) {
      if (uniqueList.isEmpty() || (id != uniqueList.get(uniqueList.size() - 1))) {
        uniqueList.add(id);
      }
    }

    return uniqueList;
  }