Gets the newest entry in the view, regardless of sort order
427390
def newest(self):
        
        if self._order_by == 'newest':
            return self.first
        if self._order_by == 'oldest':
            return self.last
        return max(self.entries, key=lambda x: (x.date, x.id))
986169
def _sort(self):
        
        self.versions = OrderedDict(sorted(self.versions.items(), key=lambda v: v[0]))
1262347
def _viewEntryNumber(self, ientry, select=True):
        """"""
        # pass entry to viewer dialog
        self._viewing_ientry = ientry
        entry = self.purrer.entries[ientry]
        busy = BusyIndicator()
        self.view_entry_dialog.viewEntry(entry,
                                         prev=ientry > 0 and self.purrer.entries[ientry - 1],
                                         next=ientry < len(self.purrer.entries) - 1 and self.purrer.entries[ientry + 1])
        self.view_entry_dialog.show()
        # select entry in listview
        if select:
            self.etw.clearSelection()
            self.etw.setItemSelected(self.etw.topLevelItem(ientry), True)
1245550
def all_prev_ordered(self, commit: Commit):
        
        # TODO: This method does a lot of work, choose correct data
        # structures to make it efficient.

        viewNo, ppSeqNo = commit.viewNo, commit.ppSeqNo

        if self.last_ordered_3pc == (viewNo, ppSeqNo - 1):
            # Last ordered was in same view as this COMMIT
            return True

        # if some PREPAREs/COMMITs were completely missed in the same view
        toCheck = set()
        toCheck.update(set(self.sentPrePrepares.keys()))
        toCheck.update(set(self.prePrepares.keys()))
        toCheck.update(set(self.prepares.keys()))
        toCheck.update(set(self.commits.keys()))
        for (v, p) in toCheck:
            if v < viewNo and (v, p) not in self.ordered:
                # Have commits from previous view that are unordered.
                return False
            if v == viewNo and p < ppSeqNo and (v, p) not in self.ordered:
                # If unordered commits are found with lower ppSeqNo then this
                # cannot be ordered.
                return False

        return True
1108084
def sorted(self):
        
        if self.start < self.end:
            return self.start, self.end
        else:
            return self.end, self.start
1099735
def get_next_record(in_uid, kind='1'):
        '''
        
        '''
        current_rec = MPost.get_by_uid(in_uid)
        recs = TabPost.select().where(
            (TabPost.kind == kind) &
            (TabPost.time_create < current_rec.time_create)
        ).order_by(TabPost.time_create.desc())
        if recs.count():
            return recs.get()
        return None
577409
def select_previous(self):
        """"""
        self.footer.clear_message()

        if self.selected == 0:
            self.footer.draw_message("Cannot move beyond first toot.", Color.GREEN)
            return

        old_index = self.selected
        new_index = self.selected - 1

        self.selected = new_index
        self.redraw_after_selection_change(old_index, new_index)
662746
public function getFirstNewNotSeen()
    {
        return $this
                ->hasOne(Post::className(), ['thread_id' => 'id'])
                ->where(['>', 'created_at', $this->userView ? $this->userView->new_last_seen : 0])
                ->orderBy(['id' => SORT_ASC]);
    }
671018
static function getFirst( $return_post_id = false, $admin_mode = false ) {

		global $blog_id;

		$book_structure = static::getBookStructure();
		$order = $book_structure['__order'];
		$pos = array_keys( $order );

		reset( $pos );
		while ( $first_id = current( $pos ) ) {
			if ( $admin_mode ) {
				if ( current_user_can( 'edit_post', $first_id ) ) {
					break;
				} else {
					next( $pos );
				}
			} else {
				if ( in_array( $order[ $first_id ]['post_status'], [ 'publish', 'web-only' ], true ) ) {
					break;
				} elseif ( current_user_can_for_blog( $blog_id, 'read_private_posts' ) ) {
					break;
				} elseif ( get_option( 'permissive_private_content' ) && current_user_can_for_blog( $blog_id, 'read' ) ) {
					break;
				} else {
					next( $pos );
				}
			}
		}

		if ( $return_post_id ) {
			return (int) $first_id;
		} else {
			return ( empty( $first_id ) ) ? '/' : get_permalink( $first_id );
		}

	}
404512
def _next(self, **kwargs):
        
        spec = self._pagination_default_spec(kwargs)
        spec.update(kwargs)

        query = queries.build_query(spec)
        query = queries.where_after_entry(query, self._record)

        for record in query.order_by(model.Entry.local_date,
                                     model.Entry.id)[:1]:
            return Entry(record)
        return None
227303
def recent(self, include=None):
        
        return self._query_zendesk(self.endpoint.recent, 'ticket', id=None, include=include)
746241
function sort() {
    var state = getInternalParamsState(this);
    var entries = state.entries;
    // Array#sort is not stable in some engines
    var slice = entries.slice();
    var entry, i, j;
    entries.length = 0;
    for (i = 0; i < slice.length; i++) {
      entry = slice[i];
      for (j = 0; j < i; j++) if (entries[j].key > entry.key) {
        entries.splice(j, 0, entry);
        break;
      }
      if (j === i) entries.push(entry);
    }
    if (state.updateURL) state.updateURL();
  }
7629
def _previous(self, **kwargs):
        
        spec = self._pagination_default_spec(kwargs)
        spec.update(kwargs)

        query = queries.build_query(spec)
        query = queries.where_before_entry(query, self._record)

        for record in query.order_by(orm.desc(model.Entry.local_date),
                                     orm.desc(model.Entry.id))[:1]:
            return Entry(record)
        return None
668075
function getMostRecentRefresh(formLastUpdated, dataLastUpdated) {
  var formTimestamp = new Date(formLastUpdated).getTime();
  var dataTimestamp = new Date(dataLastUpdated).getTime();

  if (!dataLastUpdated) {
    return formLastUpdated;
  }

  if (dataTimestamp > formTimestamp) {
    return dataLastUpdated;
  } else {
    return formLastUpdated;
  }
}
1120983
def query_recent_edited(timstamp, kind='1'):
        '''
        
        '''
        return TabPost.select().where(
            (TabPost.kind == kind) &
            (TabPost.time_update > timstamp)
        ).order_by(
            TabPost.time_update.desc()
        )
151689
def most_recent_among(versions):
        
        latest = versions[0]
        for v in versions[1:]:
            if nssversion.first_older_than_second(latest, v):
                latest = v
        return latest
322641
def previous(self):
        
        if self._order_by == 'oldest':
            return self.older
        if self._order_by == 'newest':
            return self.newer
        return None