Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 4 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

05AB1E, 38 bytes

ΣžnS•f[?θ$Ÿ)*:TMûò0Æì+Ω£μ\.—g"Ý»θä•.Isk

I/O as a list of list of characters.

Port of @xigoi's Jelly answer, so make sure to upvote him/her as well!

Try it online or verify all test cases.

Explanation:

Σ # Sort the (implicit) input-list by:
 žn # Push the constant string "ABC...XYZabc...xyz"
 S # Convert it to a list of characters
 •f[?θ$Ÿ)*:TMûò0Æì+Ω£μ\.—g"Ý»θä•
 "# Push compressed integer 3928442642485912187600397757783525135099072511850472479412437675482
 .I # Get the 392...482nd permutation of the stringcharacter-list
 s # Swap to get the current list of characters
 k # And get the index of each character in the permutation
 # (and we sort on those lists of indices)
 # (after which the sorted list is output implicitly as result)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why •f[?θ$Ÿ)*:TMûò0Æì+Ω£μ\.—g"Ý»θä• is 3928442642485912187600397757783525135099072511850472479412437675482. (Note that it's 1 lower than the number used in the Jelly answer, because 05AB1E uses 0-based indexing and Jelly uses 1-based indexing instead. This number is generated with the Œ¿ Jelly builtin This number is generated with the œ¿ Jelly builtin.)

05AB1E, 38 bytes

ΣžnS•f[?θ$Ÿ)*:TMûò0Æì+Ω£μ\.—g"Ý»θä•.Isk

I/O as a list of list of characters.

Port of @xigoi's Jelly answer, so make sure to upvote him/her as well!

Try it online or verify all test cases.

Explanation:

Σ # Sort the (implicit) input-list by:
 žn # Push the constant string "ABC...XYZabc...xyz"
 S # Convert it to a list of characters
 •f[?θ$Ÿ)*:TMûò0Æì+Ω£μ\.—g"Ý»θä•
 "# Push compressed integer 3928442642485912187600397757783525135099072511850472479412437675482
 .I # Get the 392...482nd permutation of the string
 s # Swap to get the current list of characters
 k # And get the index of each character in the permutation
 # (and we sort on those lists of indices)
 # (after which the sorted list is output implicitly as result)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why •f[?θ$Ÿ)*:TMûò0Æì+Ω£μ\.—g"Ý»θä• is 3928442642485912187600397757783525135099072511850472479412437675482. (Note that it's 1 lower than the number used in the Jelly answer, because 05AB1E uses 0-based indexing and Jelly uses 1-based indexing instead. This number is generated with the Œ¿ Jelly builtin.)

05AB1E, 38 bytes

ΣžnS•f[?θ$Ÿ)*:TMûò0Æì+Ω£μ\.—g"Ý»θä•.Isk

I/O as a list of list of characters.

Port of @xigoi's Jelly answer, so make sure to upvote him/her as well!

Try it online or verify all test cases.

Explanation:

Σ # Sort the (implicit) input-list by:
 žn # Push the constant string "ABC...XYZabc...xyz"
 S # Convert it to a list of characters
 •f[?θ$Ÿ)*:TMûò0Æì+Ω£μ\.—g"Ý»θä•
 "# Push compressed integer 3928442642485912187600397757783525135099072511850472479412437675482
 .I # Get the 392...482nd permutation of the character-list
 s # Swap to get the current list of characters
 k # And get the index of each character in the permutation
 # (we sort on those lists of indices)
 # (after which the sorted list is output implicitly as result)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why •f[?θ$Ÿ)*:TMûò0Æì+Ω£μ\.—g"Ý»θä• is 3928442642485912187600397757783525135099072511850472479412437675482. (Note that it's 1 lower than the number used in the Jelly answer, because 05AB1E uses 0-based indexing and Jelly uses 1-based indexing instead. This number is generated with the œ¿ Jelly builtin.)

Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

05AB1E, 38 bytes

ΣžnS•f[?θ$Ÿ)*:TMûò0Æì+Ω£μ\.—g"Ý»θä•.Isk

I/O as a list of list of characters.

Port of @xigoi's Jelly answer, so make sure to upvote him/her as well!

Try it online or verify all test cases.

Explanation:

Σ # Sort the (implicit) input-list by:
 žn # Push the constant string "ABC...XYZabc...xyz"
 S # Convert it to a list of characters
 •f[?θ$Ÿ)*:TMûò0Æì+Ω£μ\.—g"Ý»θä•
 "# Push compressed integer 3928442642485912187600397757783525135099072511850472479412437675482
 .I # Get the 392...482nd permutation of the string
 s # Swap to get the current list of characters
 k # And get the index of each character in the permutation
 # (and we sort on those lists of indices)
 # (after which the sorted list is output implicitly as result)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why •f[?θ$Ÿ)*:TMûò0Æì+Ω£μ\.—g"Ý»θä• is 3928442642485912187600397757783525135099072511850472479412437675482. (Note that it's 1 lower than the number used in the Jelly answer, because 05AB1E uses 0-based indexing and Jelly uses 1-based indexing instead. This number is generated with the Œ¿ Jelly builtin.)

AltStyle によって変換されたページ (->オリジナル) /