There are three different categories of reports about the compilation of the Quran:
A) The Quran that we have possession of today with all its structure and compilation, the numbering of its verses, and the structure of its chapters and sections is the very same Quran that the Prophet Muhammad gathered, collated, compiled and structured for Muslims during his life at the instigation of Allah. Although he himself did not collect the verses but the Quran was compiled under his supervision. 
B) The Quran in its present form was collected and completed by the Commander of the Faithful, Ali (a.s) following the demise of the Holy Prophet (s). The compilation was done during the time when Ali (a) was confined to his house living a secluded life.
3) The Quran was compiled after the demise of the Prophet (s) by some of the companions (sahaba) other than Imam Ali (a).
A great many Shia scholars especially the contemporaries maintain that the Quran was compiled at the time of the Holy Prophet himself and under his supervision.
Some Shiite scholars subscribe to the second category of reports saying that the Commander of the Faithful, Ali (a) was the first to collect and compile the Quran in its present shape. Most of the Sunni scholars, however, have adopted the third viewpoint. The orientalists have also advocated the same, and they have added that the Quran which was compiled by Imam Ali (a) was rejected by the companions.
Obviously, according to the first and second viewpoints, the collection of the Quran is ascribed to God and that the creation, structuring and arrangement of the verses have been done in the light of the divine revelation because the Apostle of God (s) according to verses 2 and 3 of chapter of al-Najm did not speak of his own desire. "It is naught but revelation that is revealed." Whatever the Prophet (s) was saying in religious matters was with divine guidance. As for the Infallible Imams (a), they were not receiving revelations but they were carrying on the path of the prophets; they were inerrant and possessed divine knowledge.
Those who have accepted the third viewpoint (or the third category of verses) not only cannot prove that the chapters and their order have been created with divine guidance but they also negate them and consider the personal view of the companions to be involved in the compilation of the Quran and in the arrangement of its chapters.
Here it is necessary to make mention of a few points:
1. Allamah Muhammad Hussein Tabatabai says under verse 9 of Al-Hijr [«انا نحن نزلنا الذکر و انا له لحافظون»] the features which have been mentioned for the Quran such as eloquence, expressiveness, coherence and the miraculous nature of the Quranic verses entirely exist in the present Quran which we have possession of. He has concluded that this Quran is the very same Quran which was known during the Apostle of God – peace and blessing of Allah be upon him.
Although this saying negates any kind of distortions with the Quran, it cannot prove that this collection with its present form is revelatory. That is because the aforementioned features are not in a way such as to prove that the present collection of the verses which form the chapters, and also the order of the chapters which form the Quran are in the same way as existed in the time of the Prophet (s).
2. If one can prove the numerical miracle of the Quran over and above the Quranic syntactical and conceptual arrangement of the words and chapters of the Quran and if he can establish the numerical relations of the verses of one chapter with those of another (something which mankind is unable to do), he can prove that the Suras cum their order are revelatory but again the order of the all the Quranic verses in a single chapter being revelatory will not be proved.
Reference for further reading:
Hadavi Tehrani, Mahdi, Theological Foundations of Ijtihad, pg.54 – 55, Khana-e Kherad Cultural Institute, Qom 1st edition, 1998.
 - See: Sayyid Abdul Wahhab Taliqani, The Sciences of the Quran, pg.83.
 - See: Sayyid Muhammad Reza Jalali Naeni, History of the Compilation of the Quran, pg. 87
 - Majority of Sunni scholars subscribe to this view. Ibid, pg.19 – 51.
 - See: Sayyid Abdul Wahhab Taliqani, The Sciences of the Quran, pg83; Sayyid Ali Milani, Al-Tahqiq fi Nafi al-Tahrif 'Anil-Quran al-Sharif, pg.41 – 42 and pg. 46; Muhammad Hadi Ma'refat, Protection of the Quran from Distortion, pg.34.
 - See: Sayyid Muhammad Reza Jalali Naeni, History of the Compilation of the Quran, pg.80
 -«ما ینطق عن الهوى ان هو الا وحى یوحى» Al-Najm: 2 – 3
 - We have, without doubt, sent down the Message; and We will assuredly guard it (from corruption). [15:9]
 - See: Allamah Tabatabai, Tafsir Al-Mizan, vol.12, pg.104 and pg.106 and pg.138.