Junior — Senior
Filtering and sorting strings from a collection based on a condition
livecode
Task condition
In the class, two properties are declared:
- SourceList – the initial set of strings, for example: {"string", "string2", "string3"}
- ResultList – should be filled with elements from SourceList that:
- Start with the letter s;
- Are sorted in descending order. It is required to implement the Method1 method, which will form ResultList according to the specified rules.
public class SomeClass
{
public List<string> SourceList { get; set; } = new List<string>() { "string", "string2", "string3" };
public void Method1()
{
var filtered = new List<string>(SourceList);
// filtering and sorting logic should be here
}
}