Let say that we have the JavaScript array `arr`, where each `arr[i]` contains a sentence. Now If we want to search for the sentences that contain a particular string `str`, we can use `match` to find these sentence using 

```
var newarr = [];                
for(var i = 0; i < arr.length; i++) {
if(arr[i].toLowerCase().match(str.toLowerCase()){       
newarr[newarr.length] = arr[i];             
}
}

```

The new array `newarr` will contain only the sentence that contain the string `str`. Now, is there a way to rearrange `newarr` so that the sentences containing `str` in beginning be first, then the ones that containing `str` in the middle then the ones containing `str`in the end?