Reference sorting within the .bst file

I am using a master thesis template which was prepared from my university. But when I compile my thesis, the references are sorting alphabetically instead of by appearance in the document. I have one .bst file. But I couldn't find any clue about "sorting" or "ordering" in the .bst file. So how could I change the sorting from alphabetically to appearance order in the file from my .bst file ?

-
Welcome to TeX.sx! You should tell us which .bst file you use (and provide a link if it's not available at CTAN). – lockstep Dec 18 '12 at 17:40
It's also worth noting that if your university provides a template then presumably they expect alphabetical reference sorting. – Joseph Wright Dec 18 '12 at 17:41
@lockstep here is my bib.bst file: gist.github.com/4335953 JosephWright yes you' re right. They mentioned in the "How to write" section, there are 2 ways to sort references that you can choose. But they didn't prepare the example for sorting appearance in the document.. – Yirmidokuz Dec 19 '12 at 16:26

Your bibtex style seems to be an older makebst style, so probably you are using the natbib package. To get entries sorted by order of citation, use the unsrtnat style. Further options are unsrt, and unsrturl.

Edit Looking closer at the style file you provided, there really is no sorting going on, so you should get your references in order of citation. I tried

\documentclass{article}
\providecommand{\bolum}{Chapter }

\begin{document}
\cite{incollection-minimal}
\cite{inbook-minimal}
\cite{article-minimal}

\bibliographystyle{Yirmidokuz}  % that is the style file you provided
\bibliography{xampl}  % this is an example bibliography that is contained in all TeX distributions
\end{document}


and got:

As you can see, the references are in order of citation. Are you sure that you use the style file you provided?

-
I am using the style file at gist.github.com/4335953. Because it helps me to design my bibliography as my university wanted. But still I cannot the way out for sorting them by order of citation. – Yirmidokuz Jan 18 '13 at 11:37
@Yirmidokuz I updated my answer. – mafp Jan 18 '13 at 13:02
yes, I am totally sure that I am using the style file provided above. The weird thing is that, in the document first citation takes the number two and the number one goes to citation of an image which is placed much after than the place of the text cited as number 2. – Yirmidokuz Jan 18 '13 at 13:21
Wait, you have images of your document in the bibliography?! You should not do that. The bibliography is only for things that you actually cite, e.g., books and articles. If you want a separate list of the figures in your document, use \listoffigures. – mafp Jan 18 '13 at 20:39
thank you very much!! that' s it. Perfect! – Yirmidokuz Jan 19 '13 at 0:53

Sorting of the references is indeed controlled by the bst file. This is not something that you should be changing separately: Choose a bst file that is suited for (presumably) numeric citation style, and it will almost certainly sort by order of citation. (If you're using the name-year citation style, you should be sorting your references alphabetically as well). If you otherwise like the looks of the style you have, identify it here and ask about look-alikes.

PS. bst files are written in a strange stack language that I recommend you don't bother with. Unless you have a very strange style, you'll find the sort command about 30 lines from the bottom of the file. It looks like this:

SORT

-
There is not any word like sort. I can not find it. I uploaded the .bst file. You can check there: gist.github.com/4335953 – Yirmidokuz Dec 19 '12 at 11:10