Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. private bool _isFirstAlphabetical(string actual, string next)
  2. {
  3. if (actual.Length < next.Length)
  4. {
  5. for (int stringIndex = 0; stringIndex < actual.Length; ++stringIndex)
  6. {
  7. if (Char.ToLower(actual[stringIndex]) > Char.ToLower(next[stringIndex]))
  8. return true;
  9. else if (actual[stringIndex] == next[stringIndex])
  10. continue;
  11. else
  12. return false;
  13. }
  14. return false;
  15. }
  16. else
  17. {
  18. for (int stringIndex = 0; stringIndex < next.Length; ++stringIndex)
  19. {
  20. if (Char.ToLower(actual[stringIndex]) > Char.ToLower(next[stringIndex]))
  21. return true;
  22. else if (actual[stringIndex] == next[stringIndex])
  23. continue;
  24. else
  25. return false;
  26. }
  27. return false;
  28. }
  29. }
  30.  
  31.  
  32. public string[] podleAbecedy()
  33. {
  34. string[] words = this.getSlova();
  35. for (int i = 0; i < words.Length; ++i)
  36. {
  37. for (int j = 0; j < words.Length - 1; ++j)
  38. {
  39. string temp;
  40. if (_isFirstAlphabetical(words[j], words[j + 1])) // tady se vola ta privatni fce nahore
  41. {
  42. temp = words[j];
  43. words[j] = words[j + 1];
  44. words[j + 1] = temp;
  45. }
  46. }
  47. }
  48. return words;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement