Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Within an array class, I am trying to create a sort method using comparator. Wit

ID: 3591988 • Letter: W

Question

Within an array class, I am trying to create a sort method using comparator. With what I have, the ideal is to create a temporary array, copy it from my instance variable E[] list, sort it(temporary array) with array.sort, then copy it back, though my array sort is most likely wrong. I would like to see how array sort and comparator are used together and get this method to work thank you.

public void sort(Comparator<E> c){
E[] copyArray;
copyArray = (E[]) new Object[size];
System.arraycopy(list, 0, copyArray, 0, size-1);
Arrays.sort(copyArray,c); // most likely wrong
System.arraycopy(copyArray, 0, list, 0, size-1);

Explanation / Answer

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

                    DataKeyNames="EmployeeID" DataSourceID="SqlDataSource1"

                          Font-Names="Verdana"

                    Font-Size="14px" Width="289px">

                    <Columns>

                        <asp:BoundField DataField="LastName" HeaderText="LastName"

                            SortExpression="LastName" />

                        <asp:BoundField DataField="FirstName" HeaderText="FirstName"

                            SortExpression="FirstName" />

                        <asp:TemplateField HeaderText="Useless Group">

                            <ItemTemplate>

                                    <asp:RadioButton ID="MyRadioButton" runat="server"

                                        GroupName="UselessGroup" />

                            </ItemTemplate>

                        </asp:TemplateField>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote