/// <summary> /// Order documents for searching /// </summary> /// <param Name="documents">The list of documents to search</param> /// <param Name="startDoc">The index of the document to start searching at</param> /// <param Name="reverse">Whether the search should be backwards</param> /// <returns></returns> protected static Document[] OrderDocuments(Document[] documents, int startDoc, bool reverse) { //If the search is backwards, reverse the list //And update the startDoc pointer to the new location if (reverse) { documents = documents.Reverse().ToArray(); startDoc = documents.Length - startDoc - 1; } //Reorder the list such that all documents from before the start document //are removed and added to the end of the list return documents.Skip(startDoc).Concat(documents.Take(startDoc + 1)).ToArray(); }