-3

I have this method:

public static IEnumerable<string> GetWords(string path, Func<string,Boolean> s)
        {
            
            Array.Sort(array, (first, last) => first.Length.CompareTo(last.Length));
        }
        

I want to get the Array.Sort outside the GetWords method. Is there a simple way to do this?

timz
  • 1
  • 2

1 Answers1

1

I assume you mean, "I want to sort the result of GetWords, but thats not an Array, its an IEnumerable so I cant use Array.Sort - how do I do that?"

var list = GetWords(....);
var sorted = list.OrderBy(s=>s);

see How to sort an IEnumerable<string>

pm100
  • 48,078
  • 23
  • 82
  • 145