# NodeBox

Create visual output with Python programming code
Home Download Reference Tutorial Library Gallery About

# google.sort()

## Syntax

    sort(list, key=None, strict=True)

## Description

This powerful command sorts the items in list according to the results() count Google yields on an item. As such, we assume that the entire internet is some sort of "emotive opinion" on the subject.

Setting a key sorts the items according to their relation to this key; for example sorting [red, green, blue] by love yields red as the highest result, likely because red is the color commonly associated with love. Setting a key often yields strange, illogical and unpredictable results. Just like with people.

This algorithm does not process a weight for each item. This apparently influenced the results in a bad way: like red bananas and green love.

The returned value is a list of 2-tuples. Each tuple contains a percentual count and a value, tuples are grouped descending according to their count.

## Example

In this example, Google is queried for apples, to see if there are more results returned for green apples than red apples. This Google sort indicates that people on the web talk more about green apples (70%) than red apples (30%).

    google = ximport("google")
    google.license("E4RRrGcASKIvbCtG43DFHHERRv78ghjg")
    print google.sort(["green", "red"], "apple")
    >>>[(0.6935630099728014, 'green'), (0.30643699002719854, 'red')]

You could parse the returned value as follows:

    result = google.sort(["green", "red"], "apple")
    count, value = result[0]
    print "The winner is: " + value + " (" + str(int(count*100)) + "%)"
    >>>The winner is: green (69%)