What program lets you rate many things by comparing two at a time?
May 2, 2008 8:56 PM   Subscribe

Help me find a program/web app that sorts lists by asking you to compare two items at a time.

I'm pretty sure I've actually seen this program (web site? Excel sheet?) somewhere, but I only remember the basic concept.

It works like this: You type in/import a list of things (e.g. book titles). Then the program asks you "Which do you like better, X or Y?" Then, "Which do you like better, Y or Z?" And so on and so on. Eventually it spits out your list, but now it's ordered according to your preferences (from favorite to least favorite).

Does anyone know where I can find this... sorter thingy?
posted by hjo3 to Computers & Internet (8 answers total) 2 users marked this as a favorite
 
Compile the following in C++, run it, and include your list's file name (a text file with one item per line) as the single command line argument.
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>

int comparator ( const void* lhsp, const void* rhsp ) {
    const std::string& lhs = *(static_cast<const std::string*>(lhsp));
    const std::string& rhs = *(static_cast<const std::string*>(rhsp));
    char which = 'X';

    while(1) {
        std::cout << "\t\t1. " << lhs << "\nor\t\t2. " << rhs << std::endl;
        std::cin >> which;
        std::cin.clear();
        switch(which) {
            case '1' : return -1;
            case '2' : return 1;
        }
    }
}
    

int main(int c, char**cv) {
    
    if( c != 2 ) {
        std::cout << "Usage:\n " << cv[0] << " text_file_of_items_one_per_line.txt" << std::endl;
        return 1;
    }
    
    std::fstream f(cv[1]);
    std::vector<std::string> v;
    std::string s;
    while( getline(f,s) ) {
        v.push_back(s);
    }
    
    std::cin.clear();
    
    std::qsort(&v[0], v.size(), sizeof(std::string), comparator) ;
    
    for( int i = 0 ; i < v.size(); ++i) {
        std::cout << i + 1 << ".\t\t" << v[i] << "\n";
    }
    
    return 0;
}

posted by orthogonality at 9:55 PM on May 2, 2008


Sounds like you want an interactive version of the quick sort, that asks you for subjective "better than" judgements at each comparison.

Should be relatively easy to code up, but I'm not sure how you would deal with real-life ambiguous opinion problems. For example, depending on my mood, I might say Bob Dylan is better than AC/DC. Other days, I might not. I might be inconsistent in my answers even during a single sort procedure, which would screw it up.
posted by ctmf at 10:27 PM on May 2, 2008


ctmf -- You're right, but I'm having a hard time figuring out another way to rank hundreds of items such that I don't make lots of mistakes or feel overwhelmed.

orthogonality -- Holy cow! Did you code that just for me? That's very cool. I did notice a teensy quirk though: When running it on a list of eight movies, it sometimes asks me to make the same comparison twice. Example:
$ orthosort list.txt
                1. ghostbusters
or              2. metropolis
2
                1. metropolis
or              2. clerks II
2
                1. akira
or              2. metropolis
2
                1. clerks II
or              2. metropolis
1
                1. mrs. doubtfire
or              2. metropolis
2
                1. ghost world
or              2. metropolis
1
                1. adaptation
or              2. metropolis
1
                1. ghostbusters
or              2. metropolis
2
But other than that, it's perfect. And even with the redundancy it'll work. Thanks!
posted by hjo3 at 2:27 AM on May 3, 2008


If you get to write your own, the quick sort process could be speeded up by asking multiple-selection questions. For instance: "Which of these movies is better than ghostbusters?"
posted by ctmf at 11:15 AM on May 3, 2008


Holy cow - this is why we don't use C++ for simple problems!

perl -e 'print sort { print "1) $a or\n2) $b"; readline STDIN eq "1\n" ? -1 : 1 } <>;' book_titles
posted by nicwolff at 11:49 AM on May 3, 2008


hjo3 writes "orthogonality -- Holy cow! Did you code that just for me?"

Yes and no. Yes, I did code it in response to your question. But...

nicwolff writes "Holy cow - this is why we don't use C++ for simple problems!"

... I was also feeling a bit rusty in C++, and wanted to write some simple C++ code. Admittedly, the perl code is more elegant (though it seems to have an intent error, where the newlines after each choice rely on the newline being present in the unsorted list).

Avoiding the same comparison twice was why I used qsort rather than std::sort. std::sort uses a comparator that provides a strict weak ordering, so it needs to do the comparison twice to determine if a and b are equal: , (!comp(a, b)) && !comp(b,a), meaning a is not less than b and b is not less than a (and thus they are "equal", or at least sort the same). qsort's comparator can return equal explicitly, so fewer redundant comparisons.

But I expected quicksort to do no redundant compares, as it compares everything to a pivot value, then quicksorts the set of values less than the pivot, then quicksorts the values greater than the pivot. In each case, a pivot is selected from the (sub)list of values to be sorted, so I'm having a hard time understanding the redundant compares.
posted by orthogonality at 3:23 PM on May 3, 2008


though it seems to have an intent error, where the newlines after each choice rely on the newline being present in the unsorted list

I was trimming them off, and printing them myself, but why? Worst case, if the data file has no newline at the end, there'll be a little layout change in that prompt - a small price to pay for doing in 77 characters (one of them an unnecessary ";") what took C++ 37 lines and five libraries...

I wouldn't say mine is more elegant than yours - they both express the same implementation - it's just shorter, and faster to write.
posted by nicwolff at 5:09 PM on May 3, 2008


That's a neat perl solution nicwolff. I also like how orthogonality's C++ checks somewhat for valid command line input, and makes liberal use of const. Short scripting tasks are sometimes the most fun to do the "right" way!

Regarding, the original question, here's my contribution, if you happen to have Mathematica:

Sort[ReadList["list.txt"], #1 == ChoiceDialog["Which is less?", {#1, #2}] &]
posted by hAndrew at 7:22 AM on May 4, 2008


« Older Maintenance left paint on things. What now?   |   Group activities that prove how very, very wrong... Newer »
This thread is closed to new comments.