! sort.tes - sorts lines in edit buffer into ascending or decending order ! ! call: :EIsort$ for ascending order ! ! -1:EIsort$ for decending order ! !sort.tec! [C [F [H [L [P [X ! save working registers ! +0UF ! entry arg (none=0) into F.num ! Z/40UC ! calculate the display interval ! QCUX ! initiallize the display counter ! J ! start of buffer ! L ! +1 line ! QF"L @O!decending! ' ! iif decending sort ! !ascending! < ! loop ! .-Z; ! until end of buffer ! .UH ! remember start of line ! L ! advance a line ! .UP ! remember after line ! QH,.X_ ! store line in search string buffer ! QH,.K ! kill the line (faster than -K) ! 0UL ! clear low position ! < ! loop ! QL-QH; ! exit if we have advanced to H ! QH-QL/2+QLJ ! jump to half the distance between L and H ! 0L ! then backup to the start of the line ! .UF ! rember in front of tne line ! ^QF=^["L ! if line (to right) is before (search string) ! .UL ! . becomes low position (after line) ! F< ! continue ! ' ! endif ! QFUH ! in front of line becomes high position ! > ! end loop ! QLJ ! jump to the insert position ! G_ ! insert the line ! QPJ ! jump to the next line to process ! .-QX"L F< ' ! iif not display time continue ! ^^X^T ! else type an X ! QC%X$ ! advance the display position ! > ! end loop ! @O!done! !decending! < .-Z; ! until end of buffer ! .UH ! remember before the line ! L ! advance a line ! .UP ! remember after line ! QH,.X_ ! store line in search string buffer ! QH,.K ! kill the line (faster than -K) ! 0UL ! clear low position ! < ! loop ! QL-QH; ! exit if we have advanced to H ! QH-QL/2+QLJ ! jump to half the distance between L and H ! 0L ! then backup to the start of the line ! .UF ! rember in front of tne line ! ^QF=^["G ! if line (to right) is after (search string) ! .UL ! . becomes low position (after line) ! F< ! continue ! ' ! endif ! QFUH ! in front of line becomes high position ! > ! end loop ! QLJ ! jump to the insert position ! G_ ! insert the line ! QPJ ! jump to the next line to process ! .-QX"L F< ' ! iif not display time continue ! ^^X^T ! else type an X ! QC%X$ ! advance the display position ! > ! end loop ! !done! @^A% % ! display ! ]X ]P ]L ]H ]F ]C ! restore registers !