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

16
LINES

< > BotCompany Repo | #1020477 // lowestByField

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2522L/16K).

static <A> A lowestByField(Iterable<A> l, S field) {
  A lowest = null;
  O lowestValue = null;
  for (A a : unnull(l)) {
    O val = getOpt(a, field);
    if (lowest == null || cmp(val, lowestValue) < 0) {
      lowest = a;
      lowestValue = val;
    }
  }
  ret lowest;
}

static <A> A mapMethodLike lowestByField(S field, Iterable<A> l) {
  ret lowestByField(l, field);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020477
Snippet name: lowestByField
Eternal ID of this version: #1020477/5
Text MD5: 261b24a1d6be5f112cbbc2c49a31c412
Transpilation MD5: 2ef2adc942221a52373e0cdf1c12b19e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-09-04 22:14:47
Source code size: 391 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 354 / 428
Version history: 4 change(s)
Referenced in: [show references]