def main(): print( "SortStringArray_Demo" ) print # variable arguments sortStringParametersAscending( "one", "two", "three", "four", "dog", "5", "six", "7", "house", "butterfly") print # List as argument sortStringParametersDescending( [ "one", "two", "three", "four", "dog", "5", "six", "7", "house", "butterfly" ] ) return def sortStringParametersAscending( *strings ) : # variable arguments print 'SortStringParameters Ascending' if len( strings ) == 0: print "Empty" else: print "Original: ", strings strings = sorted( strings ) print "Sorted: ", strings return def sortStringParametersDescending( strings ) : # List as argument print "SortStringParameters - Descending" if not strings: # another way to check if strings list is empty print "Empty" else: print "Original: ", strings strings.sort( reverse = True ) print "Sorted: ", strings return main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question