MarcoP wrote:
Imagine a datalist with 10 documents that are presented on the screen 'un-ranked', so the user can go through each one and rank one at a time in any order. That's our requirements
p.s. if u help me come up with a solution, i'll throw a 'I Love LLBLGenPro' bumper sticker on my ride!
Heh
Ok, here we go
simple bucket class:
public class Bucket
{
public int Rank { get; set}
public Document RankedDocument { get; set;}
}
Ok, now you dump every document in a List<Bucket>.
You then sort it on Rank.
When the user ranks a document on the screen, you go to its bucket and set the rank again. Now, traverse the list and check if there are other buckets with the same rank. If so, increase the rank with one. Now pick THAT rank and repeat the process. Process stops when you end up at the end of the list with a rank so there are no duplicates.
This is the initial algo. It isn't that efficient, so it might need some lookup thingies here and there, although traversing 10 documents is really really fast.