English Stroke Count Alphabet
In a Chinese glossary/index for any given book, to find terms that are contained within the book and because Chinese doesn't have an alphabet like in English, they are sorted by stroke count instead. (一畫 = 1 stroke,二畫 = 2 strokes,三畫 = 3 strokes,四畫 = 4 strokes,and so on)
An English glossary, having an alphabet, is naturally sorted alphabetically. For this challenge, we flip that idea to the Chinese manner. And we'll follow some Chinese writing rules to help determine stroke order for the alphabet below.
Take 口 (kou) for example, a simple square. You'd think it is 4 strokes, but it is actually 3. The 1st being the left vertical line, the 2nd being the top horizontal and right vertical in one fluid stroke, and the 3rd being the lower horizontal line. This pattern, among others, holds relatively true across Chinese characters. For sake of simplicity though, and for some diversity in the English Stroke Count Alphabet, this will be the primary pattern used.
First, I need to define stroke count for each letter. For sake of simplicity, and somewhat subjectively, I'll use the characters as they appear below. If there are any arguments why a letter should have a different stroke count, please make your case, but in order to promote diversity in stroke counts, I made some personal judgment calls. These stroke counts could easily change with different fonts.
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
3 3 1 2 4 3 2 3 3 1 3 2 4 3 1 2 2 3 1 2 1 2 4 2 3 3
a b c d e f g h i j k l m n o p q r s t u v w x y z
2 2 1 2 2 2 2 2 3 2 3 2 3 2 1 2 2 2 1 2 2 2 4 2 2 3
Letters with equal stroke counts should retain the original alphabetic order as before. So the English Stroke Order Alphabet is as follows. (If I made an error, please say as much, there are a lot of examples that I might have to adjust)
C J O S U D G L P Q T V X A B F H I K N R Y Z E M W
c o s a b d e f g h j l n p q r t u v x y i k m z w
The Challenge Given a non-empty string input containing a sentence/series of words, or a list of words, organize all words according to this new English Stroke Count alphabet. Output can be either a string, or a list of properly words is a single string of properly organized words, including duplicates should they exist.
Note 1: If upper and lowercase for the same letter have the same stroke count, uppercase letters take precedence.
- "Cousin" precedes "cousin"
- "father" precedes "Father" (because lowercase f is 2 strokes, while the uppercase is 3)
- "Stop" precedes "soap" (while the o would precede t in stroke count, uppercase S precedes lowercase s)
- KO precedes kO (K precedes k)
- kO precedes ko (O precedes o)
Note 2: I've intentionally avoided weird words in input. Inputs such as "WeIrD", "COVID-19". Input will never include any numbers, punctuation, or special characters.
Input / Output
"It was the best of times it was the worst of tImes" / "of of best the the tImes times It it worst was was"
["When", "life", "gives", "you", "lemons", "make", "Lemonade"] / ["gives", "Lemonade", "lemons", "life", "you", "When", "make"]
[The, journey, of, a, thousand, miles, begins, with, one, step,] / [of, one, step, The, a, begins, journey, thousand, miles, with]
"English Stroke Count Alphabet" / "Count Stroke Alphabet English"
"A man a plan a canal panama" / "canal a a panama plan A man"
"Carry on my wayward son" / "Carry on son my wayward"
"Close our store and begin destroying every flower green house just lose no people quietly rather than using vexing xrays yesterday it killed my zoo wombat" / Same as input
(If you can write a better sentence than above, I'd be much appreciated.)
["May", "the", "Force", "be", "with", "you"] / ["be", "the", "you", "Force", "May", "with"]
[Im, going, to, make, him, an, offer, he, cant, refuse] / [cant, offer, an, going, he, him, refuse, to, Im, make]
"jello Jello JellO JEllo JELlo JELlO JELLO" / "JellO Jello JELLO JELlO JELlo JEllo jello"
"We suffer more often In imagination than IN reality" / "often suffer reality than In IN imagination more We"
"Code Golf and Coding Challenges" / "Code Coding Challenges Golf and"
["Do", "or", "DO", "not", "there", "is", "no", "try"] / ["or", "DO", "Do", "no", "not", "there", "try", "is"]
"Failure the best teacher is" / "best teacher the Failure is"
"Can you tell that I am a Star Wars fan" / "Can Star a am fan tell that you I Wars"
[enough examples no more words] / [enough examples no more words]