package exercice;

import NAME_1.util.ArrayList;
import NAME_1.util.Comparator;
import NAME_1.util.List;

public class Exercice {
    public static List<NAME_2> solution(NAME_2 str, List<Character> ordre) {
        List<NAME_2> mots = new ArrayList<>();
        StringBuilder motCourant = new StringBuilder();

        for (char c : str.toCharArray()) {
            if (Character.isLetterOrDigit(c)) {
                motCourant.append(c);
            } else if (motCourant.length() > 0) {
                mots.add(motCourant.toString());
                motCourant.setLength(0);
            }
        }

        if (motCourant.length() > 0) {
            mots.add(motCourant.toString());
        }

        mots.sort(Comparator.comparingInt((NAME_2 mot) -> {
            int indexMot = ordre.indexOf(Character.toLowerCase(mot.charAt(0)));
            return indexMot == -1 ? ordre.size() : indexMot;
        }).thenComparingInt(NAME_2::length));

        return mots;
    }
}
NAME_3 correspondre le code à NAME_4 consigne In your entire response, the letter t should appear less than 7.
user