KTUG마당은 KTUG를 방문하는 모든 이용자가 대화를 나누고 소식을 전하는 곳입니다.
- 로그인 없이 자유롭게 글을 읽고 쓸 수 있는 철학은 처음과 같이 계속됩니다.
- Team Blog의 글을 이곳 게시판의 "정보글"로 모았습니다. Team blog는 기고자가 올린 글에 질문을 받는 부담을 줄이기 위하여 댓글을 허용하지 않았습니다. 그러나 이곳 게시판으로 모으면서 댓글을 달 수 있습니다. 게시물을 작성하실 때 댓글을 원하지 않으시면 댓글을 허용하시지 않으시기를 바랍니다. 또한 불필요한 소모성 댓글을 달지 않도록 주의하여 주시기를 바랍니다.
- TeX과 관련된 질문이나 답변은 QnA 마당을 이용하십시오. TeX과 관련된 질문은 지웁니다
- MathJax를 이용한 수식조판을 사용하실 수 있습니다. 여기를 참조하세요.
- 스팸 글을 막기 위하여 짧은 시간 내에 다시 글이 등록되는 IP를 막거나, 광고 글을 막기 위하여 금지어로 .com, .net 등을 설정하고 있습니다. 다소간의 불편함이 있으시더라도 양해 바랍니다.
- 금지어에서 stackexchange, stackoverflow, ctan, overleaf, , github, google.com, gmail.com, .org, .io, sil.org, wiki.com, tistory.com등은 해제하였습니다.
- 사용하는 편집기는 CKeditor입니다. 편집기에서 [enter]를 누르면 <p> 태그가 들어가고, 문단으로 생각하고 한줄을 비웁니다. 글줄만 바꾸려면 shift-enter 를 누르시면 <BR>가 들어가므로 용도에 맞게 나누어 쓸 수 있습니다.
문자열 정렬에 대해서는 DohyunKim 님의 http://www.ktug.or.kr/xe/index.php?document_srl=33728 이 있다.
다음 소스는 xfor 패키지에서 가져온 것으로 원래 숫자에 대해서만 삽입정렬하게 한 것인데 윗글의 \pdfstrcmp를 이용하여 문자열 정렬을 시도해보았다.
정렬 방식은 삽입정렬(insertion sort)
\documentclass{oblivoir}
\usepackage{xfor}
\makeatletter
\newcommand{\insertinto}[2]{%
\def\nlst{}% new list initially empty
\@for\n:=#2\do{%
% store new list in \toks@
\expandafter\toks@\expandafter{\nlst}%
% test current value against new value
%%%\ifnum\n>#1\relax %%%
\ifnum\pdfstrcmp{\n}{#1}=1\relax
% new value needs to be inserted before current value
\edef\newstuff{#1,\n}%
% end for loop at the end of this iteration
\@endfortrue
\else
\edef\newstuff{\n}%
\fi
% append new stuff to new list
\ifx\nlst\@empty
\edef\nlst{\newstuff}%
\else
\edef\nlst{\the\toks@,\newstuff}%
\fi
}%
% check to see if for loop was prematurely terminated
\if@endfor
% loop may have been terminated during final iteration, in
% which case \@forremainder is empty.
\ifx\@forremainder\@empty
% do nothing
\else
% loop prematurely ended, append remainder of original list
% to new list
\expandafter\toks@\expandafter{\nlst}%
\edef\nlst{\the\toks@,\@forremainder}%
\fi
\else
% wasn't prematurely terminated, so new value hasn't been added
% so add now.
\expandafter\toks@\expandafter{\nlst}%
\ifx\nlst\@empty
\edef\nlst{#1}%
\else
\edef\nlst{\the\toks@,#1}%
\fi
\fi
\global\let#2=\nlst
}
\newcommand*{\insertionsort}[1]{%
\def\sortedlist{}%
\@for\val:=#1\do{{\insertinto{\val}{\sortedlist}}}%
\let#1=\sortedlist
}
\makeatother
\begin{document}
\def\chlist{받,은,편,지,함,의,메,일,을,모,두,읽,으,셨,습,니,다}
\insertionsort{\chlist}
\chlist
\def\chlist{{독도는},{우리},{땅이다},{민족},{국가},{자유}}
\insertionsort{\chlist}
\chlist
\end{document}
결과:
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
628 | TeX Live 2018 [5] | 지나가다 | 2018.04.28 | 7319 |
627 | Cygwin을 써야 할 세 가지 이유 | karnes | 2012.04.18 | 7319 |
626 | LuaLaTeX을 활용한 고서적 조판 [8] | 옛한글 | 2019.06.13 | 7305 |
625 | grruby와 "선언서" [2] | noname | 2019.05.17 | 7298 |
624 | MiKTeX 2.9에서 cjk-ko와 xetexko 사용하기 | karnes | 2013.10.25 | 7146 |
623 | 루비 [5] | noname | 2019.05.22 | 7144 |
622 | 문단의 첫 글자를 크게 [6] | yihoze | 2017.08.17 | 7134 |
621 | TeX Live 2019와 xindex [3] | noname | 2019.05.04 | 7125 |
620 | 설문: 레이텍 과정 [31] | yihoze | 2018.07.04 | 7085 |
619 | [참가신청] 문서작성워크숍 2016 [10] | ischo | 2016.10.11 | 7038 |
618 | prepare font file [9] | nanim | 2014.07.04 | 6971 |
617 | 그럭저럭 또 하나의 Sample pdf 를 만들어 봤습니다. [2] | 불량양파 | 2016.11.23 | 6958 |
616 | 공주대 문서작성 워크숍에 많이 참석해주세요. [7] | Progress | 2016.10.25 | 6868 |
615 | 만화진흥원체 테스트 [10] | 에드 | 2016.05.15 | 6858 |
614 | 부산체도 있네요.. | glue | 2011.03.22 | 6851 |
613 | TL2014의 memhangul-x.sty [2] | yihoze | 2014.07.11 | 6850 |
612 | 팀블로그 게시판 권한에 대하여 [2] | Kriss | 2019.02.18 | 6838 |
611 | 메무아 매뉴얼 서문의 1890년대풍 번역 [4] | noname | 2019.07.16 | 6835 |
610 | 텍라이브 업데이트 후 "\ifx가가" 에러 [7] | ischo | 2014.08.01 | 6828 |
609 | kotex-sections.sty [1] | nanim | 2014.06.05 | 6802 |