Quick sort implementation in python

"Martin v. Löwis" martin at v.loewis.de
Thu Sep 25 16:47:52 EDT 2008


> Now as you can see I'm passing my list object to both functions along
> with their first, last indices

I cannot really see that. More specifically, it isn't definite what the
type of the "a" argument is, nor does the specific type of "a" matter
for the algorithm. It could be a list, or it could be a different
mutable collection that is integer-indexed.

> My question is: Is that the normal way to implement algorithms in
> python

Yes, it is.

> cause in c++ i've implemented that algo via a template function
> which can have a randon access data structure or not. However i have
> no idea how to access the values of a data structure that doesn't
> allow random access.

Can you please explain how you did that in C? IOW, how did you do
the partition function (template) in case you don't have random
access to the collection?

Regards,
Martin



More information about the Python-list mailing list