Stream map ordering comparison

    0

    0

    Manuel Antunes

    : A: B: D: F: C: E: H: G:

    List<String> lstColonnesOrigine = Arrays.asList("A", "B", "C", "D", "E", "F", "G", "H");
      List<String> listeDesLignesDuFichierAImporter = Arrays.asList("A", "B", "D", "F", "C", "E", "H", "G");
      String[] lignesSuivantes = {"AA", "BB", "DD", "FF", "CC", "EE", "HH", "GG"};
    
    // donne la correspondance entre pour trier lignesSuivantes dans l'ordre de lstColonnesOrigine
      List<Integer>indexes = lstColonnesOrigine.stream()
          .map(colonne -> listeDesLignesDuFichierAImporter.indexOf(colonne))
          .collect(Collectors.toList());
    
      for (int i=0;i<8;i++){
                System.out.print(": " +lignesSuivantes[indexes.get(i)]);
            }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.