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 comments total)
2 users marked this as a favorite
#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