AppleScript名:1D Listを文字列長でソート v3 |
— Created 2014-11-25 by Shane Stanley use AppleScript version "2.4" use scripting additions use framework "Foundation" set aList to {"Apple", "Orange", "Banana", "Meron", "Strawberry", "Lemon", "Takaaki Naganoya", "Piyomaru Software"} set bList to sort1DListByStringLength(aList as list, true) of me –昇順 –> {"Apple", "Lemon", "Meron", "Banana", "Orange", "Strawberry", "Takaaki Naganoya", "Piyomaru Software"} set cList to sort1DListByStringLength(aList as list, false) of me –降順 –> {"Piyomaru Software", "Takaaki Naganoya", "Strawberry", "Banana", "Orange", "Apple", "Lemon", "Meron"} –1D Listを文字列長でソート v2 on sort1DListByStringLength(aList as list, sortOrder as boolean) set aArray to current application’s NSArray’s arrayWithArray:aList set desc1 to current application’s NSSortDescriptor’s sortDescriptorWithKey:"length" ascending:sortOrder set desc2 to current application’s NSSortDescriptor’s sortDescriptorWithKey:"self" ascending:true selector:"localizedCaseInsensitiveCompare:" set bArray to aArray’s sortedArrayUsingDescriptors:{desc1, desc2} return bArray as list of string or string end sort1DListByStringLength |
More from my site
(Visited 35 times, 1 visits today)