Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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)
Comment

sorted

// for 2 strings s1 and s2 to be anagrams
// both conditions should be True
// 1 their length is same or 
len(s1)==len(s2)
// 2 rearranging chars alphabetically make them equal or 
sorted(s1)==sorted(s2)
Comment

PREVIOUS NEXT
Code Example
Python :: full_like numpy 
Python :: python reverse range 
Python :: list all files in a folder 
Python :: determine how 2 string si equal py 
Python :: python selenium driver 
Python :: 3d data visualization python 
Python :: convert string to datetime python 
Python :: django action when create model 
Python :: check for null values in rows pyspark 
Python :: pyspark on colab 
Python :: access list index python 
Python :: get last item on list 
Python :: dataframe change index 
Python :: pandas df number of columns 
Python :: if list element contains string python 
Python :: convert date to string in python 
Python :: start virtualenv with python version 
Python :: cast as float python 
Python :: Python RegEx Subn – re.subn() 
Python :: python in 
Python :: how to change help command on discord python 
Python :: perfect numbers python 
Python :: return more than one value python 
Python :: add an item to a dictionary python 
Python :: prompt python 
Python :: crud python 
Python :: numpy array into tuple 
Python :: //= python meaning 
Python :: how to add space in python 
Python :: full body tracking module 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =