@sed -i 's/, \\py@release//' build/latex/sphinx.sty
@sed -i '/-makeindex/d' build/latex/Makefile
@cp manual.cls build/latex/
+ @./bibsort.py
@echo
@echo "Build finished; the LaTeX files are in build/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
--- /dev/null
+#!/usr/bin/env python
+
+import re
+
+fname = 'build/latex/tesis.tex'
+
+bib_re = re.compile(r'(\\begin{thebibliography}{[^}]+})'
+ r'(.*)'
+ r'(\\end{thebibliography})',
+ re.S)
+
+text = file(fname).read()
+
+head, body, foot = bib_re.findall(text)[0]
+
+body = '\n'.join(
+ sorted(
+ body
+ .replace('\n', '')
+ .replace('\\bibitem', '\n\\bibitem')
+ .splitlines()
+ )
+ )
+
+text = bib_re.sub('\n'.join((head, body, foot)).replace('\\', '\\\\'), text)
+
+#print text
+file(fname, 'w').write(text)
+