> By default, the sorted function looks at the leftmost element of a tuple or other iterable, when sorting...
AFAIU, sorted() compares the whole object. https://docs.python.org/3/howto/sorting.html >>> l = [(3, 2), (3, 1), (1, 1, 2), (1, 1)] >>> sorted(l) [(1, 1), (1, 1, 2), (3, 1), (3, 2)] The way it reads, it seems like you're implying that sorted() does this: >>> l = [(3, 2), (3, 1), (1, 1, 2), (1, 1)] >>> sorted(l, key=lambda x: x[0]) [(1, 1, 2), (1, 1), (3, 2), (3, 1)] > You'll find some excellent overview of the magic methods in this essay by Rafe Kettler: A Guide to Python's Magic Methods. He's mostly looking at Python 2.7, so does not pick up on the __next__ method, however you'll be able to fill in the blanks thanks to this course This is unclear to me. What does the next() function do? How do I find the docs and source for it? These are misspelled: > comparitor > compartor These are great: - http://www.scipy-lectures.org/intro/language/python_language.html - http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-1-Introduction-to-Python-Programming.ipynb - Something about sorted with a link to the docs would be a good addition. IDK, I tend to find it much easier to just read the docs (and the source, if it's not clear). https://docs.python.org/3/library/functions.html#sorted https://docs.python.org/3/howto/sorting.html sorted() is a built-in function (as indicated by the TypeError thrown by inspect.getfile(sorted)); which are in bltinmodule.c: https://github.com/python/cpython/blob/master/Python/bltinmodule.c On Wednesday, August 29, 2018, kirby urner <kirby.ur...@gmail.com> wrote: > > >> I tested that out in my OrderingPolys.ipynb (Jupyter Notebook). Great! >> I'm keeping the demo. >> >> http://localhost:8889/notebooks/Documents/SAISOFT/ >> SAISOFT/OrderingPolys.ipynb >> > > > https://github.com/4dsolutions/SAISOFT/blob/master/OrderingPolys.ipynb > > Sorry, my bad. I gave the local URL on my laptop vs the global one @ > Github. > > Kirby > >>
_______________________________________________ Edu-sig mailing list Edu-sig@python.org https://mail.python.org/mailman/listinfo/edu-sig