Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

18
LINES

< > BotCompany Repo | #1013287 // compareIgnoreCase_lower - uses toLower method

JavaX fragment (include)

static int compareIgnoreCase_lower(S s1, S s2) {
  if (s1 == null) ret s2 == null ? 0 : -1;
  if (s2 == null) ret 1;
  
  int n1 = s1.length();
  int n2 = s2.length();
  int min = Math.min(n1, n2);
  for (int i = 0; i < min; i++) {
    char c1 = s1.charAt(i);
    char c2 = s2.charAt(i);
    if (c1 != c2) {
      c1 = Character.toLowerCase(c1);
      c2 = Character.toLowerCase(c2);
      if (c1 != c2) ret c1-c2;
    }
  }
  ret n1-n2;
}

Author comment

Began life as a copy of #1004962

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1013287
Snippet name: compareIgnoreCase_lower - uses toLower method
Eternal ID of this version: #1013287/1
Text MD5: 7c33d41b0a26d28f58ef0fd58a0e75b8
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-31 07:26:36
Source code size: 456 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 481 / 510
Referenced in: [show references]