title: How to sort alphabetically rows of a data frame?
body: <p>I am tring to sort <code>c</code> alphabetically <code>if x[i]== x[i+1]</code>. I used <code>order()</code> function but it changes the <code>x</code> column as well. I want to order the entire row:</p>
  
  <pre><code> best &lt;- function(state){
   HospitalName&lt;-vector()
   StateName&lt;-vector()
   HeartAttack&lt;-vector()
  
    k&lt;-1
  
    outcome&lt;-read.csv("outcome-of-care-measures.csv",colClasses= "character")
  
   temp&lt;-(outcome[,c(2,7,11,17,23)])
  
  for (i in 1:nrow(temp)){
   if(identical(state,temp[i,2])==TRUE){
      HospitalName[k]&lt;-temp[i,1]
      StateName[k]&lt;-temp[i,2]
      HeartAttack[k]&lt;-as.numeric(temp[i,4])
      k&lt;-k+1
       }}
      frame&lt;-data.frame(cbind(HospitalName,StateName,HeartAttack))
  
  
    library(dplyr)
    frame %&gt;%
    group_by(as.numeric(as.character(frame[,3]))) %&gt;%
    arrange(frame[,1])
      }
  
    Output:
                                 HospitalName StateName HeartAttack
   1              FORT DUNCAN MEDICAL CENTER        TX         8.1
   2         TOMBALL REGIONAL MEDICAL CENTER        TX         8.5
   3        CYPRESS FAIRBANKS MEDICAL CENTER        TX         8.7
   4                  DETAR HOSPITAL NAVARRO        TX         8.7
   5                  METHODIST HOSPITAL,THE        TX         8.8
   6         MISSION REGIONAL MEDICAL CENTER        TX         8.8
   7  BAYLOR ALL SAINTS MEDICAL CENTER AT FW        TX         8.9
   8       SCOTT &amp; WHITE HOSPITAL-ROUND ROCK        TX         8.9
   9         THE HEART HOSPITAL BAYLOR PLANO        TX           9
   10    UT SOUTHWESTERN UNIVERSITY HOSPITAL        TX           9
  ..                                    ...       ...         ...
  Variables not shown: as.numeric(as.character(frame[, 3])) (dbl)
  </code></pre>
  
  <p>Output does not contain the HeartAttack Column and I do not understand why?</p>