Finds and returns the order (0-based) of a POJO field.
Returns -1 if the field does not exist for this POJO.
970144
private int findField(String fieldName) {
		int foundIndex = 0;
		for (Field field : fields) {
			if (field != null && fieldName.equals(field.getName())) {
				return foundIndex;
			}

			foundIndex++;
		}

		return -1;
	}
72929
function fieldReorder(elem, field, val, pos) {
        try {
            $(exports).triggerHandler('fieldReorder', [elem, field, val, pos]);
        } catch (err) {
            console.error(err);
        }
        _currentOperation.ops.push({
            op: OP_FIELD_REORDER,
            arg: {
                _id: elem._id,
                f: field,
                e: val._id,
                i: pos
            }
        });
    }
1197807
def order fields
      by_num = { 1 => 'asc', -1 => 'desc' }
      ordering = []
      fields.each_pair do |key, value|
        ordering << [key.to_s, by_num[value] || value]
      end
      @ordering = ordering
      self
    end
784794
@Override
	public int lastIndexOf(Object elem) {
		if (elem == null) return -1;
		if (elem instanceof Number) return lastIndexOf(((Number)elem).longValue());
		return -1;
	}
1331762
def _calculate(self, field):
        '''
        
        '''
        base_offset = 0
        if self.base_field is not None:
            base_offset = self.base_field.offset
        target_offset = self._field.offset
        if (target_offset is None) or (base_offset is None):
            return 0
        return target_offset - base_offset
194740
public int indexOf(Object o) {
		try {
			for (int i = 0; i < events.size(); i++) {
				if (events.get(i).equals(o)) {
					return i;
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}
968061
Rule FieldNumber() {
		return Sequence(
				ZeroOrMoreS(FirstOfS(Eols().suppressNode(),
								Comment(), Xcommand(), Tex())),
				String("X:"),
				ZeroOrMore(WSP()).suppressNode(),
				DIGITS(),
				HeaderEol()
			).label(FieldNumber);
	}
1218344
def get_ordering_field_columns(self):
        

        # We must cope with more than one column having the same underlying
        # sort field, so we base things on column numbers.
        ordering = self._get_default_ordering()
        ordering_fields = OrderedDict()
        if ORDER_VAR not in self.params:
            # for ordering specified on model_admin or model Meta, we don't
            # know the right column numbers absolutely, because there might be
            # morr than one column associated with that ordering, so we guess.
            for field in ordering:
                if field.startswith('-'):
                    field = field[1:]
                    order_type = 'desc'
                else:
                    order_type = 'asc'
                for index, attr in enumerate(self.list_display):
                    if self.get_ordering_field(attr) == field:
                        ordering_fields[index] = order_type
                        break
        else:
            for p in self.params[ORDER_VAR].split('.'):
                none, pfx, idx = p.rpartition('-')
                try:
                    idx = int(idx)
                except ValueError:
                    continue  # skip it
                ordering_fields[idx] = 'desc' if pfx == '-' else 'asc'
        return ordering_fields
799963
public boolean containsBeforeSchemaOrder(String field) {
    if (schemaOrderIndex == null) {
      return containsFieldName(field);
    }
    for (int i = 0; i < schemaOrderIndex; i++) {
      if (elements.get(i).getName().equals(field)) {
        return true;
      }
    }
    return false;
  }
1028895
public int compareTo(Field field)
    {
        if (field instanceof BaseField) if (!this.isSameType((BaseField)field))
            return super.compareTo(field);
        double double1 = Double.MIN_VALUE, double2 = Double.MIN_VALUE;
        Double doubleField = (Double)this.getData();    // Get the physical data
        if (doubleField != null)
            double1 = doubleField.doubleValue();
        doubleField = (Double)field.getData();  // Get the physical data
        if (doubleField != null)
            double2 = doubleField.doubleValue();
        if (double1 == double2)
            return 0;
        if (double1 < double2)
            return -1;
        else
            return 1;
    }
473395
private boolean isEqual(FieldDescriptorDef first, FieldDescriptorDef second)
    {
        return first.getName().equals(second.getName()) &&
               first.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN).equals(second.getProperty(PropertyHelper.OJB_PROPERTY_COLUMN)) &&
               first.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE).equals(second.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));
    }
753783
@Override
	public int compareTo(JSONDocFieldWrapper o) {
		if(this.getOrder().equals(o.getOrder())) {
			return this.getField().getName().compareTo(o.getField().getName());
		} else {
			return this.getOrder() - o.getOrder();
		}
	}
261996
public int compareTo(Field field)
    {
        if (field instanceof BaseField) if (!this.isSameType((BaseField)field))
            return super.compareTo(field);
        short short1 = Short.MIN_VALUE, short2 = Short.MAX_VALUE;
        Short tempShort = (Short)this.getData();    // Get the physical data
        if (tempShort != null)
            short1 = tempShort.shortValue();
        tempShort = (Short)field.getData();   // Get the physical data
        if (tempShort != null)
            short2 = tempShort.shortValue();
        if (short1 == short2)
            return 0;
        if (short1 < short2)
            return -1;
        else
            return 1;
    }
1358295
public int indexOf(int ele) {
        int i;

        for (i = 0; i < size; i++) {
            if (data[i] == ele) {
                return i;
            }
        }
        return -1;
    }
511833
function sortFactory(key) {
  return function sortNumeric(a, b) {
    if (b[key] < a[key]) {
      return -1;
    }
    if (b[key] > a[key]) {
      return 1;
    }
    return 0;
  };
}
1069625
def lookup_field_orderable(self, field):
        
        try:
            self.model._meta.get_field_by_name(field)
            return True
        except Exception:
            # that field doesn't exist, so not sortable
            return False
145595
def find_one(self, filter=None, fields=None, skip=0, sort=None):
        
        result = self.find(filter=filter, fields=fields, skip=skip, limit=1, sort=sort)
        if len(result) > 0:
            return result[0]
        else:
            return None