Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. f1 = Mod[#, 4] &;
  2. f2 = Mod[#, 7] &;
  3.  
  4. SortBy[Range@10, {f1, f2}]
  5.  
  6. {#, f1@#, f2@#} & /@ % // Grid
  7.  
  8. {8, 4, 1, 9, 5, 2, 10, 6, 7, 3}
  9.  
  10. string = {"cat", "fish", "catfish", "Cat"};
  11. Sort[string]
  12. out: {"cat", "Cat", "catfish", "fish"}
  13.  
  14. ToCharacterCode[string]
  15. out: {{99, 97, 116}, {102, 105, 115, 104}, {99, 97, 116, 102, 105, 115,104}, {67, 97, 116}}
  16.  
  17. SortBy[ToCharacterCode[string], First]
  18. out: {{67, 97, 116}, {99, 97, 116}, {99, 97, 116, 102, 105, 115, 104}, {102, 105, 115, 104}}
  19.  
  20. FromCharacterCode[
  21. SortBy[ToCharacterCode[string], First]
  22. ]
  23. out: {"Cat", "cat", "catfish", "fish"}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement