{ "info": { "author": "Matthew Rocklin", "author_email": "mrocklin@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Partially Ordered Sort\n======================\n\nAn algorithm to sort a collection by a sequence of comparators.\n\nComparators\n-----------\n\nA comparator takes two elements `a` and `b` and returns\n \n `0` - if they are equal\n a positive number if `a > b`\n a negative number if `a < b`\n\nFor example the natural comparator on the integers is \n\n def small_first(a, b):\n return a - b\n\nThe Python `sorted` function takes a comparator function as a keyword input\n\n >>> sorted([1, 5, 2, 4, 3], cmp=small_first)\n [1, 2, 3, 4, 5]\n\nWe may choose to sort by different criteria. For example we might choose to\nprefer even numbers\n\n def evens_first(a, b):\n return a%2 - b%2\n \n >>> sorted([1, 5, 2, 4, 3], cmp=evens_first)\n [4, 2, 5, 1, 3]\n\nNote in the example above that all of even numbers precede all of the odd numbers; `evens_first` is satisfied. Also note that there are several possible solutions. In this case there are `12` possible solutions that all satisfy the comparator function. `sorted` returns one at random. \n\n`posort`\n--------\n\nTo obtain the solution `[2, 4, 1, 3, 5]` where numbers are sorted first by evenness and then by magnitude we can use the function `posort`.\n\nThe `posort` function attempts to satisfy a sequence of comparator functions of decreasing precedence.\n\n >>> posort([1, 5, 2, 4, 3], evens_first, small_first)\n [2, 4, 1, 3, 5]\n\nThe rule for even numbers dominates the rule for small numbers. Any number of comparator functions can be specified.\n\n\nEquivalent structures\n---------------------\n\nA comparator function completely specifies a \n[partial order](http://en.wikipedia.org/wiki/Partial_order#Formal_definition). \n\nA comparator function can describe any \n[directed acyclic graph (DAG)](http://en.wikipedia.org/wiki/Directed_acyclic_graph)\n\n\nAuthor\n------\n\n[Matthew Rocklin](http://matthewrocklin.com)\n\nLicense\n-------\n\nNew BSD license. See LICENSE.txt\n\nHistory\n-------\n\nThis idea was originally developed for the\n[Theano project](http://github.com/theano/theano)", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/mrocklin/posort", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "posort", "package_url": "https://pypi.org/project/posort/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/posort/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/mrocklin/posort" }, "release_url": "https://pypi.org/project/posort/0.1/", "requires_dist": null, "requires_python": null, "summary": "Partially ordered sort", "version": "0.1" }, "last_serial": 770294, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "87c9c6364cdf7a74e2676a1bd32105b8", "sha256": "607d5da848fcbe816c775cab932af06f7c3eb864a9df0e4f278fcea43ddc110a" }, "downloads": -1, "filename": "posort-0.1.tar.gz", "has_sig": false, "md5_digest": "87c9c6364cdf7a74e2676a1bd32105b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3145, "upload_time": "2013-06-13T18:08:57", "url": "https://files.pythonhosted.org/packages/d7/a0/bf2d42a38c5eb5a552b9d1d9bc643b531dd57d5b500f888bae43ef5d1b18/posort-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "87c9c6364cdf7a74e2676a1bd32105b8", "sha256": "607d5da848fcbe816c775cab932af06f7c3eb864a9df0e4f278fcea43ddc110a" }, "downloads": -1, "filename": "posort-0.1.tar.gz", "has_sig": false, "md5_digest": "87c9c6364cdf7a74e2676a1bd32105b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3145, "upload_time": "2013-06-13T18:08:57", "url": "https://files.pythonhosted.org/packages/d7/a0/bf2d42a38c5eb5a552b9d1d9bc643b531dd57d5b500f888bae43ef5d1b18/posort-0.1.tar.gz" } ] }