TLDR: Sort your input according to a new English alphabet somewhat based on Chinese stroke count methods.
Background: In a Chinese glossary/index, finding terms that are contained within the book is different from English because Chinese doesn't have an alphabet like English, instead they are sorted by stroke count.
(一畫 = 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 somewhat to follow the Chinese manner. And we'll follow some Chinese writing rules to help determine stroke order for the alphabet below.
Counting Strokes: 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, forming the corner. And the 3rd being the lower horizontal line, completing the square. This pattern, among others, holds relatively true across Chinese characters. For sake of simplicity though, and for some added diversity in the English Stroke Count Alphabet, there is a somewhat subjective choice for stroke counts.
Defining the NESCA 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 again in order to promote diversity in stroke counts, I made some personal judgment calls. For example,
W could arguably be done in 2 strokes, where each stroke makes a
v shape, but if that was the case for every letter, this new alphabet would essentially resemble the original. Hence my subjective choice of stroke counts. (For those that also read/speak Mandarin, 不好意思！)
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. The only tie-breaker should be upper and lower case letters with the same stroke counts.
C and c, O and o, S and s, D and d, etc. 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
and more specifically...
Note 1: Tiebreakers - 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)
- make precedes When (both have 4 strokes, but m precedes W in the original alphabet)
Note 2: Input will never include any numbers, punctuation, or special characters, nor will it be empty.
Note 3: I left this challenge in the Sandbox for 2 weeks as a precaution. I'm worried a lot of people will argue against my subjective decisions in defining this alphabet (especially the letter
g). I merely tried to allow for a very new and very different alphabet, and to add more diversity to Challenges.
The Challenge Given a string input containing a sentence, series of words, or a list of words, organize those words according to the NESCA. 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.
EDIT At the behest of users, I have changed my examples to be one consistent input/output format. My example formats can be found here, and exact examples can be obviously found in edit history.
Example Format 1
"INPUT HERE" / "OUTPUT HERE"
Example Format 2
[INPUT HERE] / [OUTPUT HERE]
Example Format 3
["INPUT", "HERE"] / ["OUTPUT", "HERE"]
Any suitable format for your language, as per community standards.
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 make When"
"The journey of a thousand miles begins with one step" / "of one step a begins journey The 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 Zachs mini wombat" / Same as input (If you can write a better sentence than above, I'd be much appreciated. I'd gift reputation, but I don't know how)
"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 him hE refuse to Im make"
"jello Jello JellO JEllo jellO JELlo JELlO jEllo JELLO JelLo JeLlo" / "JeLlo JelLo JellO Jello JELLO JELlO JELlo JEllo jellO jello jEllo" (Annoyed? Me too!)
"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 and Golf"
"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"