;+
; NAME:
;	SMEI_SEQUENCE::SORT
;
;
; PURPOSE:
;	Sorts the images of a SMEI sequence into time order.
;
;
; CATEGORY:
;	SMEI_SEQUENCE
;
;
; CALLING SEQUENCE:
;	seqref -> sort
;
;
; SIDE EFFECTS:
;	The order of the images in the sequence is changed.
;
; PROCEDURE:
; 	Simple minded slide sort, this will still sort the biggest
; 	mess that something with 1GB can cope with in well under a
; 	second. 
;
;
; MODIFICATION HISTORY:
;	Original: 13/1/03; SJT
;-

pro smei_sequence::sort

repeat begin
    im = self -> get_first()
    next = im -> get_next()
    nswap = 0l
    while obj_valid(next) do begin
        st0 = im -> get_time(/start)
        st1 = next -> get_time(/start)
        if st0 gt st1 then begin
            junk = next -> move(-1)
            nswap = nswap+1
        endif else begin
            im = next
        endelse
        next = im -> get_next()
    endwhile
endrep until nswap eq 0

end
