public static Double SortJaroWinklerDistance(String firstWord, String secondWord, int numRemoveLetters)
    {
        double defaultMismatchScore = 0.0;

        if ((firstWord != null) && (secondWord != null))
        {
            //Use SortString Function to sort String
            String sortedFirstString  = UserDefinedFunctions.SortString(firstWord, " ", numRemoveLetters);
            String sortedSecondString = UserDefinedFunctions.SortString(secondWord, " ", numRemoveLetters);

            double cSortJaroWinklerDistance = UserDefinedFunctions.JaroWinklerDistance(sortedFirstString, sortedSecondString);

            // Return value Sorted JaroWinklerDistance
            return(cSortJaroWinklerDistance);
        }
        return(defaultMismatchScore);
    }
    public static Double PermutedJaroWinklerDistance(String firstWord, String secondWord)
    {
        double similarity           = 0;
        double defaultMismatchScore = 0.0;

        if ((firstWord != null) && (secondWord != null))
        {
            //Use CleanUpProductName and ToUpperInvariant to clean String
            String firstString  = UserDefinedFunctions.CleanUpProductName(firstWord.ToUpperInvariant());
            String secondString = UserDefinedFunctions.CleanUpProductName(secondWord.ToUpperInvariant());
            int    numberWord   = UserDefinedFunctions.CountStringSize(firstString, secondString);

            List <string> ls1 = firstString.Split(' ').ToList();
            List <string> ls2 = secondString.Split(' ').ToList();

            // Permuta apenas strings com tamanho inferior a numberWords (e.g, 4)
            if (ls2.Count <= numberWord && ls1.Count <= numberWord && numberWord <= 4)
            {
                IList <IList <string> > perm1 = UserDefinedFunctions.Permutations(ls1);
                IList <IList <string> > perm2 = UserDefinedFunctions.Permutations(ls2);

                foreach (var item1 in perm1)
                {
                    string str1 = string.Join(" ", item1.ToArray());
                    foreach (var item2 in perm2)
                    {
                        string str2 = string.Join(" ", item2.ToArray());
                        similarity = Math.Max(similarity, UserDefinedFunctions.JaroWinklerDistance(str1, str2));
                    }
                }
                // Return value permuted JaroWinklerDistance
                return(similarity);
            }
            else
            {
                similarity = UserDefinedFunctions.JaroWinklerDistance(firstString, secondString);
                return(similarity);
            }
        }
        return(defaultMismatchScore);
    }