“Combined Sort” further

One reader expressed need for an example. So, here we go.

Student X sits down to evaluate his options for employment and writes this way:

Company I Want Can Money Peer Pressure
Google Yes No Good Yes
Froogle No Yes Bad Yes
Doodle Yes Yes Good Yes

… and the list is VERY big – say option of applying to 50 companies. The decision he wants to take is, which companies to focus on.

For this, he decides to focus on the parameters “I want”, “Can” and “Money”.

Then he should be able to sort and find Google and Doodle nearby – because 2 out of 3 parameters are the same, when compared Froogle, for which 3 parameters are different.

As Dr. Yash Vasavada mentions in his reply to the previous post on this topic, these results may be weighed further. [Yash, I had used weighted parameters in my first major decision making. How good the set of parameters was is a different question :-)]

***

Now comes the algorithm part.

1. Take the parameters on which to sort (in our case “I want”, “Can” and “Money”)

2. Take the table and convert into a view (in our case the table as shown above)

3. Add a column “TempSortKey” to the table (in our case imagine sixth column)

4. For each row in the table, calculate TempSortKey assuming some positive number for each possible value for the cell (in our case, we take “yes” and “Good” for 1, “no” and “Bad” for 2) and multiply with relative weight of the column (in our case 1 for “I Want”, “Can” and “Money” but 0 for “Peer Pressure”) and insert into the corresponding cell of TempSortKey (gives Google 4, Froogle 5, Doodle 3)

5. Sort the view by TempSortKey (gives Doodle, Google, Froogle)

6. Deliver the view without TempSortKey

Only step #4 requires programming – everything else is achievable with SQL.

***

I think the algorithm isn’t bullet-proof because multidimensional data may not be possible to order nicely.

I will appreciate if someone posts an implementation.

… and then I will request an implementation of “Unsort” also.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s