Program: 91097
Project: 91097
Buggy source:
public static List<WalletAccount> sortAccounts(final List<WalletAccount> accounts,final MetadataStorage storage){
  Ordering<WalletAccount> type=Ordering.natural().onResultOf(new Function<WalletAccount,Integer>(){
    @Nullable @Override public Integer apply(    @Nullable WalletAccount input){
      if (input instanceof Bip44Account) {
        return 0;
      }
      if (input instanceof SingleAddressAccount) {
        return checkIsLinked(input,accounts) ? 3 : 1;
      }
      if (input instanceof ColuAccount) {
        return 3;
      }
      if (input instanceof CoinapultAccount) {
        return 4;
      }
      return 2;
    }
  }
);
  Ordering<WalletAccount> index=Ordering.natural().onResultOf(new Function<WalletAccount,Integer>(){
    @Nullable @Override public Integer apply(    @Nullable WalletAccount input){
      if (input instanceof Bip44Account) {
        Bip44Account bip44Account=(Bip44Account)input;
        return bip44Account.getAccountIndex();
      }
      return Integer.MAX_VALUE;
    }
  }
);
  Comparator<WalletAccount> linked=new Comparator<WalletAccount>(){
    @Override public int compare(    WalletAccount w1,    WalletAccount w2){
      if (w1 instanceof ColuAccount) {
        return ((ColuAccount)w1).getLinkedAccount().getId().equals(w2.getId()) ? -1 : 0;
      }
 else       if (w2 instanceof ColuAccount) {
        return ((ColuAccount)w2).getLinkedAccount().getId().equals(w1.getId()) ? 1 : 0;
      }
 else {
        return 0;
      }
    }
  }
;
  Ordering<WalletAccount> name=Ordering.natural().onResultOf(new Function<WalletAccount,String>(){
    @Nullable @Override public String apply(    @Nullable WalletAccount input){
      return storage.getLabelByAccount(input.getId());
    }
  }
);
  return type.compound(index).compound(linked).compound(name).sortedCopy(accounts);
}

Fixed version (ground truth):
public static List<WalletAccount> sortAccounts(final List<WalletAccount> accounts,final MetadataStorage storage){
  Ordering<WalletAccount> type=Ordering.natural().onResultOf(new Function<WalletAccount,Integer>(){
    @Override public Integer apply(    @Nullable WalletAccount input){
      if (input instanceof Bip44Account) {
        return 0;
      }
      if (input instanceof SingleAddressAccount) {
        return checkIsLinked(input,accounts) ? 3 : 1;
      }
      if (input instanceof ColuAccount) {
        return 3;
      }
      if (input instanceof CoinapultAccount) {
        return 4;
      }
      return 2;
    }
  }
);
  Ordering<WalletAccount> index=Ordering.natural().onResultOf(new Function<WalletAccount,Integer>(){
    @Nullable @Override public Integer apply(    @Nullable WalletAccount input){
      if (input instanceof Bip44Account) {
        Bip44Account bip44Account=(Bip44Account)input;
        return bip44Account.getAccountIndex();
      }
      return Integer.MAX_VALUE;
    }
  }
);
  Comparator<WalletAccount> linked=new Comparator<WalletAccount>(){
    @Override public int compare(    WalletAccount w1,    WalletAccount w2){
      if (w1 instanceof ColuAccount) {
        return ((ColuAccount)w1).getLinkedAccount().getId().equals(w2.getId()) ? -1 : 0;
      }
 else       if (w2 instanceof ColuAccount) {
        return ((ColuAccount)w2).getLinkedAccount().getId().equals(w1.getId()) ? 1 : 0;
      }
 else {
        return 0;
      }
    }
  }
;
  Ordering<WalletAccount> name=Ordering.natural().onResultOf(new Function<WalletAccount,String>(){
    @Nullable @Override public String apply(    @Nullable WalletAccount input){
      return storage.getLabelByAccount(input.getId());
    }
  }
);
  return type.compound(index).compound(linked).compound(name).sortedCopy(accounts);
}