This article mainly introduces the comparison of quick sorting examples between javascript and Python. examples show simple implementation skills for quick sorting between javascript and Python, which has some reference value, for more information about how to quickly sort javascript and Python, see the examples in this article. Share it with you for your reference. The details are as follows:
Js implementation method:
Function quicksort (arr) {if (arr. length <= 1) return arr return quicksort (arr. filter (function (lt, I) {return I> 0 & lt <arr [0]}). concat ([arr [0]). concat (quicksort (arr. filter (function (ge, I) {return I> 0 & ge> = arr [0]})}
Python implementation method:
Def quicksort (arr): if len (arr) <= 1: return arr return quicksort ([lt for lt in arr [1:] if lt <arr [0]) + a [0: 1] + \ quicksort ([ge for ge in arr [1:] if ge> = arr [0])
I hope this article will help you design javascript and Python programs.