I want to sort an array of strings by whether they contain a custom pattern or not.
I have tried custom sort using comparator, but they all sort based on ascending or descending order. My requirement is as follows:
String[] strArr = { "maven", "maven_apache", "java", "multithreading", "java_stream" };
String patternToMatch = "java";
Then output should be a sorted array with strings containing the pattern java first, followed by the others:
String[] strArr = { "java", "java_stream", "maven", "maven_apache", "multithreading" };