Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python sort() and sorted()

a=[2,2,4,1]
b=a
a.sort()
// a now points to object [1,2,2,4]
c=sorted(b)
//c and b also points to [1,2,2,4] 
// sort works on array only but sorted also on strings but return array of char
s="sjndk"
print(sorted(s))
// prints ['d', 'j', 'k', 'n', 's']
// sorted also works on list of strings(sorts alphabetically)
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #python
ADD COMMENT
Topic
Name
9+5 =