code: def trim(self, n_peaks):
          
          self.sortByIntensity()
          ims.spectrum_trim(self.ptr, n_peaks)
docs: Sorts mass and intensities arrays in descending intensity order,
          then removes low-intensity peaks from the spectrum.
  
          :param n_peaks: number of peaks to keep