Manually Sorting Objects With compareTo

Hello All,
I have a quick problem I am working on. I have to implement the java compareTo interface and sort through some objects. I know this would be easier with an array, but all the comparisons of the five objects have to be done through the compareTo. For some reason, the way I am sorting is just not working... I do get output, but there is a bug in my code, and I am assured that the way I am coding is NOT the most efficient. If anyone could guide me, and help me sort the Task objects from highest to lowest based upon Complexity, it would be much appreciated.
I will try to respond as fast as possible! I have attached the Task class and the class with main below. Thanks again!
Task Class:
public class Task implements Comparable
     private String taskName;
     private int priority;
     public Task (String scheduleTaskName, int importance)
          taskName = scheduleTaskName;
          priority = importance;          
     public int compareTo(Object obj)
          Task comparedTask = (Task)obj;
          int comparedTaskPriority = comparedTask.getPriority();
          if (priority < comparedTaskPriority)
               return -1;
          else if (priority > comparedTaskPriority)
               return 1;
          else
               return 0;
     public int getPriority()
          return priority;
     public Task copySelf()
          return this;
     public String toString()
          String result = "P: " + priority + "\t " + taskName;
          return result;
}Schedule Class:
//This is the driver class for Task / Comparable implementation.
public class Schedule
     public static Task task1 = new Task("", 0);
     public static Task task2 = new Task("", 0);
     public static Task task3 = new Task("", 0);
     public static Task task4 = new Task("", 0);
     public static Task task5 = new Task("", 0);
     public static int sortHighest = 0;
     public static void main(String[]args)
          EasyReader console = new EasyReader(System.in);
          //Declare all the variables, but values will be updated as needed.
          //NOTE: These can NEVER be null or there will be errors in the compare!
          System.out.println("Welcome to the complexity scheduler program!");
          System.out.println("We can schedule up to 5 things per day, and rate how complex they are!");
          System.out.println("How many things would you like to schedule today?");
          int numberOfTasks = console.intInput();
          while (numberOfTasks > 5 || numberOfTasks < 1) //Check how valid the input is.
               System.out.println("We cannot do this many tasks... Please enter a valid number [1-5]:");
               numberOfTasks = console.intInput();
          System.out.println();
          //Read in all the tasks in an orderly manner.
          for (int x=1; x<=numberOfTasks; x++)
               System.out.println("Task number " + x + ":");
               System.out.println("Please enter the task name:");
               String taskBuffer = console.stringInput();
               System.out.println("How complex is this task to you?");
               int importanceBuffer = console.intInput();
               //Validate the entry that way the sorting will work.
               while (importanceBuffer <= 0)
                    System.out.println("Please enter a valid importance that is greater than zero! :");
                    importanceBuffer = console.intInput();
               if(x == 1)
                    task1 = new Task(taskBuffer, importanceBuffer);
               else if (x == 2)
                    task2 = new Task(taskBuffer, importanceBuffer);
               else if (x == 3)
                    task3 = new Task(taskBuffer, importanceBuffer);
               else if (x == 4)
                    task4 = new Task(taskBuffer, importanceBuffer);
               else if (x == 5)
                    task5 = new Task(taskBuffer, importanceBuffer);
               System.out.println();
          System.out.println("Thank you for entering in your tasks.");
          System.out.println("Are you ready for them to be sorted and shown? [Y/n]");
          String userChoice = console.stringInput();
          //And here is where we start to sort it.
          if (userChoice.equalsIgnoreCase("y"))
               System.out.println();
               sortHighest = numberOfTasks+1;
               for (int y=1; y <= numberOfTasks; y++)
                    Task temporaryTask;
                    if(y==1)
                         temporaryTask = sortTask(task1);
                    else if (y==2)
                         temporaryTask = sortTask(task2);
                    else if (y==3)
                         temporaryTask = sortTask(task3);
                    else if (y==4)
                         temporaryTask = sortTask(task4);
                    else
                         temporaryTask = sortTask(task5);
                    System.out.println(temporaryTask);
     public static Task sortTask(Task input)
          Task result = input;
          //And the sort goes like this...
          if (result.compareTo(task1) < 0 && task1.getPriority() < sortHighest)
               result = task1;
          if (result.compareTo(task2) < 0 && task2.getPriority() < sortHighest)
               result = task2;
          if (result.compareTo(task3) < 0 && task3.getPriority() < sortHighest)
               result = task3;
          if (result.compareTo(task4) < 0 && task4.getPriority() < sortHighest)
               result = task4;
          if (result.compareTo(task5) < 0 && task5.getPriority() < sortHighest)
               result = task5;
          sortHighest = result.getPriority() - 1;
          return result;
}

They can be sorted and stored in seperate Task
objects.. Okay, stop and think about this for a minute.
The usual way to sort is something like:Arrays.sort(someArray);
or
Collections.sort(someList);The sort routine can sort any number of objects--however many are in the list or array.
Now, your bubblesort method--like the core API's sort methods--will call your compareTo methods on pairs of your objects.
What will be the signature of your bubblesort method? Will it sort a fixed number of objects?
bubbleSort(task1, task2, task3, task4, task5)Note that it's impossible for this to even work in Java, because those references will be passed by value. There could not be a separate sort method. You'd have to implement your sort routine inline in the method where they're defined, or they'd have to be member variables. Either way, it's nonsense.
Not being able to use arrays or lists is a ridiculous requirement. I'm almost certain you misunderstood. Perhaps you're not allowed to use the Arrays.sort method.
If your teacher really said you can't use arrays, he has no business teaching this class.

Similar Messages

  • Can't seem to get sort-object working in powershell widget

    I'm experiencing a bit of exasperation with the powershell widget in SCOM 2012 - go easy on me though, this is my first time posting and I'm a bit of a newbie with powershell.
    Because of the issues with the logical disk space performance widget and multiple disks (if you have 3 disks attached you get 9 results back) I've been trying to adapt a script somebody else wrote (http://blogs.technet.com/b/lukaszr/archive/2014/06/18/how-to-get-nice-logical-disk-state-view-using-powershell-grid-widget.aspx)
    as I want something slightly different.
    My objective is to list the 10 servers with lowest free GB space. The script I've been trying to adapt just lists all disks on all servers.
    Here is my modified version of the script
    $disklist = @()
    $disks = Get-SCOMClass -Name "Microsoft.Windows.Server.LogicalDisk" | Get-SCOMClassInstance
    foreach ($disk in $disks)
    $query = GET-WMIOBJECT –query "SELECT * from win32_logicaldisk where DeviceID = '$disk'" -ComputerName $disk.Path | Select-Object Size, FreeSpace
    $size = $query.Size
    $free = $query.FreeSpace
    $percent = $free / $size
    $pervalue = "{0:P0}" -f $percent
    $sizeGB = "{0:N1}" -f ($size / 1024 / 1024 / 1024)
    $freeGB = "{0:N1}" -f ($free / 1024 / 1024 / 1024)
    $diskobject = $ScriptContext.CreateFromObject($disk, "Id=Id", $null)
    $diskobject["Server"] = $disk.Path
    $diskobject["Drive"] = $disk.Displayname
    $diskobject["FreeG"] = $freeGB
    $diskobject["FreeP"] = $pervalue
    $diskobject["FreeTotal"] = ($freeGB + " / " + $sizeGB)
    $disklist += $diskobject
    $GBdisklist = $disklist | Sort-Object -Property {[float]($_.FreeG)} | select -first 10
    foreach($thing in $GBdisklist) {
    $ScriptContext.ReturnCollection.Add($thing)
    My thinking was to put all the info into one big collection, then sort that by free disk space and select the top 10, then pipe those back into the scriptcontext collection for displaying. It's slightly unwieldy, granted, but works fine in standard powershell
    (after changing the scriptcontext bits), just not the widget!
    It all seems to work, and brings back data, except the data that comes back has clearly not been sorted before having the top 10 selected. It's as if the sort command is completely ignored. I've tried quite a few variations on the script sort/sort-object
    with or without -property in desperation as I seem to be so close, but yet so far.
    Any help would be appreciated!
    Pete.
    Incidentally, this is the script that works perfectly in standard powershell:
    $disklist = @()
    $disks = Get-SCOMClass -Name "Microsoft.Windows.Server.LogicalDisk" | Get-SCOMClassInstance
    foreach ($disk in $disks)
    $query = GET-WMIOBJECT –query "SELECT * from win32_logicaldisk where DeviceID = '$disk'" -ComputerName $disk.Path | Select-Object Size, FreeSpace
    $size = $query.Size
    $free = $query.FreeSpace
    $percent = $free / $size
    $pervalue = "{0:P0}" -f $percent
    $sizeGB = "{0:N1}" -f ($size / 1024 / 1024 / 1024)
    $freeGB = "{0:N1}" -f ($free / 1024 / 1024 / 1024)
    $diskobject = New-Object System.Object
    $diskobject | Add-Member -MemberType NoteProperty -Name "Id" -Value $disk.ID
    $diskobject | Add-Member -MemberType NoteProperty -Name "Server" -Value $disk.Path
    $diskobject | Add-Member -MemberType NoteProperty -Name "Drive" -Value $disk.Displayname
    $diskobject | Add-Member -MemberType NoteProperty -Name "FreeP" -Value "$pervalue"
    $diskobject | Add-Member -MemberType NoteProperty -Name "FreeG" -Value $freeGB
    $diskobject | Add-Member -MemberType NoteProperty -Name "FreeTotal" -Value ($freeGB + " / " + $sizeGB)
    $disklist += $diskobject
    $GBdisklist = $disklist | Sort-Object -Property {[float]($_.FreeG)} | select -first 10
    $GBdisklist | ft

    After hacking the code around massively I've managed to solve the issue with it and made it a lot neater in the process. Still unsure what the issue was, but I think it helps to sort the output of the diskinfo first before starting with any of the info processing
    / scriptcontext adding
    $disklist = @()
    $rawdisks = Get-SCOMClass -Name "Microsoft.Windows.Server.LogicalDisk" | Get-SCOMClassInstance
    foreach ($disk in $rawdisks)
    $diskdetails = GET-WMIOBJECT –query "SELECT * from win32_logicaldisk where DeviceID = '$disk'" -ComputerName $disk.Path | Select-Object PSComputerName, DeviceID, FreeSpace, Size
    $disklist += $diskdetails
    $top10disks = $disklist | Sort-Object -Property FreeSpace | select -first 10
    foreach ($object in $top10disks) {
    $size = $object.Size
    $free = $object.FreeSpace
    $percent = $free / $size
    $pervalue = "{0:P0}" -f $percent
    $sizeGB = "{0:N1}" -f ($size / 1024 / 1024 / 1024)
    $freeGB = "{0:N1}" -f ($free / 1024 / 1024 / 1024)
    $dataObject = $ScriptContext.CreateInstance("xsd://foo!bar/baz")
    $dataObject["Id"] = (($object.PSComputerName).ToString() + ($object.DeviceID).ToString())
    $dataObject["Server"] = ($object.PSComputerName).ToString()
    $dataObject["Drive"] = $object.DeviceID
    #$dataObject["Free GB"] = ($freeGB).ToString("0000.00")
    $dataObject["Free GB"] = ($freeGB).ToString()
    $dataObject["FreeTotal"] = (($freeGB).ToString() + " / " + ($sizeGB).ToString())
    $ScriptContext.ReturnCollection.Add($dataObject)

  • Objects with CLOBs

    I'm trying to implement objects with CLOBs and am having a bit of trouble. Everything works fine right up to the Clob::open() call where my program aborts (dumps core).
    I'm running the 9i client on a RedHat 9 box.
    I read in the OCCI Developers Manual about objects with Lobs but that section seems most interested in creating new objects whereas I'm simply trying to update one.
    I do an "INSERT INTO ..." and then a "SELECT REF() ..."
    In my case the whole row is the object.

    I got over this problem by just using the example from page 5-16 of the manual (funny how things work when you actually follow instructions). But now I'm having a different problem.
    I have a persistent object with CLOBs. I insert my object using the example on page 5-16. Following the Clob::write() I do an Clob::open() and a Clob::read() on the clob I just wrote. The read returns 0 and the buffer contains garbage but the row of the table actually has data.
    I thought with persistent objects I could get my data back again without having to do another query. Is this correct? What am I doing wrong?

  • Unable to drag and drop images with manual sort in CS2 bridge

    I've had CS2 for several years now but for some reason, just never really needed to do a manual sort. Now that I DO need to, it doesn't seem to be working. I have the view set for manual and no matter what kind of working space I use, the program does not allow me to drag and drop the thumbnails into different positions. All I get is that circle with a diagonal line through it, showing me that what I'm trying isn't going to work.
    Any ideas?
    Windows XP
    2G of ram
    Bridge version 1.0.4.6 (104504)
    CS2

    DUUUUUUUDE! IT'S WORKING NOW!!!!
    When you originally asked, "What happens if you click on an image and move it to another folder?", I didn't really understand what you were talking about because I almost never have my workspace set up in a way that the folders are showing. I always hide them. So I didn't really understand what you were saying. Just a few minutes ago, I realized that that is what you were asking so I opened up the folder area and tried dragging thumbs into different folders and saw that it does work.
    So then, because of you mentioning that blue line and me know that I did see the blue line on occasion. I went back over into the thumbnails to find out if I always got the blue line or if it was a hit or miss thing. I couldn't believe my eyes when all of the sudden I saw that I no longer was getting that circle with the line through it, and low and behold, the thumbnail dropped right into position like it is supposed to!!!!
    The thing is, I don't know what I've learned from this. I thought, "well, what is different?" The only thing that I can think of is that I now have the folders showing in my workspace so I wondered if that was the secret but I just now hid the folders again like I usually do and the drag and drop into position is STILL WORKING!!!
    All I can figure is that somehow, dragging and dropping a thumbnail into a folder like that for the first time, triggered something so that I can now drag and drop among the thumbnail positions? Not sure. All I know is that for some reason, IT'S WORKING NOW!
    Now, for the second important part, I wonder if I drag and drop everything into the order that I want and then select all of the files and drag them into a new folder, will they stay in that order? I need to go experiment with that.
    If you hadn't kept at it and in turn had me keep trying stuff, it would have never happened because I had pretty much given up.
    Thanks Curt!
    You da man!!!

  • Batch of files manually sorted in Bridge - Can I run a PS Action in that manual order?

    For some jobs my workflow ideally involves manually sorting the order of a batch of RAW files in Bridge (the RAW file names are as assigned by the camera) and then using a PS Action from Bridge to convert, save, and rename the batch of files. I want to end up with my image files sequentially numbered in the manually sorted order.
    However, my PS Action automatically processes the files in ascending order of their RAW file names and therefore my manually assigned file order in Bridge is lost.
    Is there a script (or other method) which will allow me to run a PS action from Bridge on a batch of files while keeping the manually sorted order for the purposes of the numbering sequence of the renamed output files?
    My current workaround is to Batch Rename in Bridge a copied set of RAW files as an intermediate step to running my PS Action on the renamed RAW file copies. It's not a bad workaround but if there is an easier way, I would much appreciate knowing about it!
    Geoff

    Geoff, here is an example that works for me. When I test ran the sample script based on some stuff that I do the files are process in the order of the manual sort and only the files in my selection are processed folders etc are ignored… I have NO idea how much people charge for this sort of thing I only do it for the learning process. If you can let me know what the Photoshop process is and your OS I 'may' be able to help but I make NO promises as Im still very much the learner with this stuff…
    You can give this a test if you like…
    #target bridge
    with (app.document) {
         if (sorts[0].type == 'user') {
              if (selections.length == 0) {
                   selectAll();
                   var userSel = selections;
                   deselectAll();
              } else {
                   var userSel = selections;
              for (var i = 0; i < userSel.length; i++) {
                   if (userSel[i].type == 'file') psProcess(userSel[i].spec);
         } else {
               alert('This window is NOT a manual sort?')
    function psProcess(filePath) {
         var psScript = 'while (app.documents.length) app.activeDocument.close(SaveOptions.PROMPTTOSAVECHANGES);' + '\n';
         psScript += 'var userDialogs = app.displayDialogs; \n';
         psScript += 'var userRulerUnits = app.preferences.rulerUnits; \n';
         psScript += 'app.diaplayDialogs = DialogModes.NO; \n';
         psScript += 'app.preferences.rulerUnits = Units.PIXELS; \n';
         psScript += 'app.bringToFront(); \n';
         // Pass File Object as toSource
         psScript += 'var thisFile = ' + filePath.toSource() + '; \n';
         psScript += 'var docRef = app.open(thisFile); \n';
         psScript += 'var baseName = docRef.name.slice(0, -4); \n';
         // Edit the document
         psScript += 'if (docRef.bitsPerChannel == BitsPerChannelType.SIXTEEN) docRef.bitsPerChannel = BitsPerChannelType.EIGHT; \n';
         psScript += 'if (docRef.mode != DocumentMode.RGB) docRef.changeMode(ChangeMode.RGB); \n';
         psScript += 'if (docRef.colorProfileName != "sRGB IEC61966-2.1") docRef.convertProfile("sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC); \n';
         psScript += 'docRef.flatten(); \n';
         // Call some functions
         psScript += 'processChannels(docRef); \n';
         psScript += 'processPaths(docRef); \n';
         psScript += 'if (docRef.pathItems.length >= 1) processSelection(docRef, 0); \n';
         psScript += 'fitImage(docRef, 880, 72); \n';     
         psScript += 'docRef.resizeCanvas(900, 900, AnchorPosition.MIDDLECENTER); \n';
         // set up new file path to save document
         psScript += 'var newFilePath = new File("~/Desktop/" + baseName + ".jpg"); \n';
         psScript += 'saveFileasJPEG(newFilePath, 9); \n';
         //      Close doc & put back prefs
         psScript += 'app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); \n';
         psScript += 'app.diaplayDialogs = userDialogs; \n';
         psScript += 'app.preferences.rulerUnits = userRulerUnits; \n';     
         // Use eval & toSource for Photoshop functions
         psScript += 'eval' + processChannels.toSource(); + '; \n';
         psScript += 'eval' + processPaths.toSource(); + '; \n';
         psScript += 'eval' + processSelection.toSource(); + '; \n';
         psScript += 'eval' + fitImage.toSource(); + '; \n';
         //psScript += 'eval' + imageArea.toSource(); + '; \n';
         //psScript += 'eval' + saveFileasTIFF.toSource(); + '; \n';
         psScript += 'eval' + saveFileasJPEG.toSource(); + '; \n';
         // Send script to Photoshop
         btMessaging('photoshop', psScript);
    General Functions
    function btMessaging(targetApp, script) {
         var bt = new BridgeTalk();
         bt.target = targetApp;
         bt.body = script;
         bt.send();
    function createFolder(folderPath) {
         var thisFolder = new Folder(folderPath);
         if (!thisFolder.exists) thisFolder.create();
    Photoshop Functions
    function processChannels(docRef) {
         for (var i = docRef.channels.length-1; i >= 0; i--) {
              if (docRef.channels[i].kind == ChannelType.MASKEDAREA) {
                   docRef.channels[i].remove();
                   continue;
              if (docRef.channels[i].kind == ChannelType.SELECTEDAREA) {
                   docRef.channels[i].remove();
                   continue;
              if (docRef.channels[i].kind == ChannelType.SPOTCOLOR) {
                   docRef.channels[i].merge();
    function processPaths(docRef) {
         if (docRef.pathItems.length >= 2) {
              for (var i = 0; i < docRef.pathItems.length; i++) {
                   if (docRef.pathItems[i].kind == PathKind.CLIPPINGPATH) {
                        docRef.pathItems[i].makeClippingPath(0.5);
                        docRef.pathItems[i].makeSelection(0, true, SelectionType.REPLACE);
                        docRef.pathItems[i].deselect();
      if (docRef.pathItems.length == 1) {
              if      (docRef.pathItems[0].kind == PathKind.WORKPATH) docRef.pathItems[0].name = 'Clipping Path'
              docRef.pathItems[0].makeClippingPath(0.5);
              docRef.pathItems[0].makeSelection(0, true, SelectionType.REPLACE);
              docRef.pathItems[0].deselect();
    function processSelection(docRef, offSet) {
         if (docRef.layers[0].isBackgroundLayer) docRef.layers[0].isBackgroundLayer = false;
         docRef.selection.expand(offSet);
         docRef.selection.invert();
         docRef.activeLayer = docRef.layers[0];
         docRef.selection.clear();
         docRef.selection.deselect();
         docRef.trim(TrimType.TRANSPARENT, true, true, true, true);
         docRef.flatten();
    function fitImage(docRef, newSize, newRes) {
      if (docRef.width >= docRef.height) {
         docRef.resizeImage(newSize, undefined, newRes, ResampleMethod.BICUBICSMOOTHER);
      else {
         docRef.resizeImage(undefined, newSize, newRes, ResampleMethod.BICUBICSMOOTHER);
    function imageArea(docRef, newArea, newRes) {
      var originalArea = docRef.width * docRef.height;
      if (originalArea > newArea) {
         var newWidth = Math.sqrt(docRef.width * newArea / docRef.height);
         var newHeight = (docRef.height * newWidth / docRef.width);
         docRef.resizeImage(newWidth, newHeight, newRes, ResampleMethod.BICUBICSMOOTHER);
      else {
         docRef.resizeImage(undefined, undefined, newRes, ResampleMethod.NONE);
    function bitmapOptions(res) {
      bitOptions = new BitmapConversionOptions();
         bitOptions.method = BitmapConversionType.HALFTHRESHOLD;
         bitOptions.resolution = res;
         bitOptions.shape = BitmapHalfToneType.SQUARE;
         return bitOptions;
    Photoshop Save As Functions
    function saveFileasTIFF(saveFile, aC, iC, la, sC, tr) {
         tiffSaveOptions = new TiffSaveOptions();
         tiffSaveOptions.alphaChannels = aC;
         tiffSaveOptions.byteOrder = ByteOrder.MACOS;
         tiffSaveOptions.embedColorProfile = true;
         tiffSaveOptions.imageCompression = iC;
         tiffSaveOptions.layers = la;
         tiffSaveOptions.spotColors = sC;
         tiffSaveOptions.transparency = tr;
         activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
    function saveFileasJPEG(saveFile, qL) {
         jpgSaveOptions = new JPEGSaveOptions();
         jpgSaveOptions.embedColorProfile = true;
         jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
         jpgSaveOptions.matte = MatteType.NONE;
         jpgSaveOptions.quality = qL;
         activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);

  • Any way to Restore Last Manual Sort Order or Prevent from being Overwritten accidentally?

         Help!
         I'm constantly accidentally overwriting painstakingly created manual sort ordering (sometimes hours but more often months of accumulated work) in folders with files numbering up to 1,000, when i, however breifly, switch to another sort ordering (size, date modified etc) to check something, immediately forget that i'm in another sort order, and, unthinkingly (actually i guess i'm thinking of a lot of other things) drag a file to another position, this immediately destroys any past manual sorting i've established, overwriting it with this new inadvertent manual ordering.
         I've tried CommandZ (edit undo) but that only undoes my last rating or labeling, i've rushed to force quit Bridge through the activity montior hoping i will catch it before its overwritten, but obviously i am not as fast as a computer, and i don't think this has ever worked.
    Is there any way or any script someone has written to formally save a manual sort order? Is there anything i've missed to attempt restoring it? Has anyone, repeatedly foiled by this, written something that would give a warning and require confirmation say for instance, if i tried to drag or move a file while in another sort ordering (this seems like something that should have existed the minute the opportunity was given to create manual organization). Would anyone be willing to?
         Seriously, me forgetting almost every time isn't going to change and, more vexingly, it's even happened when i didn't mean to move anything but fumbled momentarily while in another sort order. I think most people might forget because (in the context of computing) we are conditioned to expect a warning if something we have just created is about to be written over or discarded, and since there is no option to formally save a manual ordering we have just created.
         Also, if this was in the real world, moving a single file would not reshuffle everything on your desk. If i had the option to formally save a manual organization i would NOT forget to do this and would use it, as i've wished for one every time spent a while rearranging files. Knowing how easily all the hours (much less months and years of cumulative work) of organizational work can be accidentally lost makes working within Bridge unpleasantly anxious.
          I'm literally willing to do anything including installing some sketchy 3rd-part scripts (though honestly i have no idea what that means or how to do it). I extentively use and rely heavily upon this function so this is a fairly serious Achille's heel. It's like watching your incredibly important meticulously constructed house of cards collapse with a careless but innocent sigh, or like having the equivelent of a not even charming cat dance across your keyboard during a live concert, etc etc....
         Also it is not usually appropriate, given the context, to batch rename everything to preserve a manual ordering w sequence numbers, etc. Often the filenames are considerably (but necessarily, to connote important differences) long already, and when i have to rearrange things in the future would have to do that each time, etc, etc, making for even more unwieldly filenames that didn't have any substantive information at the beginning. I'm looking for a way to make this function (manual sort ordering), well, more functional, secure and stable, the workarounds i've considered cause too many additonal problems.
         Thank you in advance for any help you may be able to offer, and as this is my first attempt to use the forums as i live on a boat with no regular net access, would appreciate any forum etiquette corrections, and advance apologies for any misspellings, dyslexic and spellcheck does not seem to work in this interface. next time will edit in external wordprocessing program beforehand,
              li'l mc szpf
         PS i'm on a 27" mac w CS4 Design Premium, w up to the minute OS (10.6.8) and Adobe software updates installed recently (i do not often move the monster but this week was housesitting w net access, so she has had all recommended shots and vaccinations....)
         PPS I know most of y'all might be running the newest and the latest of everything, but, i'm fairly certain this is still a problem in recent versions as this has happened to me at school where all the macs are running cs5. Though if it's been addressed somehow in cs6 would update entire suite just to fix this one problem in Bridge. I've tried many searches and found nothing relevant or wouldn't bother the considerable expertise and resources of an official forum, was extremely hesitant to ask (feared getting snapped at for unwittingly broaching forum etiquette) but it is truly the bane of my considerable Bridge existence, so was willing to risk the imaginary censure and opprobrium....
    Message was edited by: PECourtejoie

    That is a good question, to do this requires two functions and a restart of Bridge all done automagically
    Copy and paste the script into ExtendScript Toolkit
    This gets installed with Photoshop and can be found:-
    PC: C:\Program Files\Adobe\Adobe Utilities
    MAC: <hard drive>/Applications/Utilities/Adobe Utilities
    Start Bridge
    PC: Edit - Preferences - Startup Scripts
    Mac: Adobe Bridge menu - Preferences - Startup Scripts
    At the bottom click the "Reveal Button" this will open the folder where the script should be saved.
    Close and restart Bridge.
    Accept the new script.
    To use:
    Tools - Backup Manual Sort
    This will backup the hidden manual sort file .BridgeSort to .BridgeSortSave
    Tools - Restore Manual Sort
    This will copy the .BridgeSortSave back to .BridgeSort and will close and restart Bridge so that the manual sort is restored.
    if( BridgeTalk.appName == "bridge" ) { 
    var backUpManSort = new MenuElement( "command","Backup Manual Sort", "at the end of Tools" , "backupms" );
    var RestoreManSort = new MenuElement( "command","Restore Manual Sort", "at the end of Tools" , "restorems" );
    backUpManSort.onSelect = function () {
    var fileSort = new File(app.document.presentationPath +"/.BridgeSort");
    var fileSave = new File(app.document.presentationPath +"/.BridgeSortSave");
    if(fileSave.exists) fileSave.remove();
    fileSort.copy(fileSave);
    fileSave.hidden=true;
    RestoreManSort.onSelect = function () {
    var fileSort = new File(app.document.presentationPath +"/.BridgeSort");
    var fileSave = new File(app.document.presentationPath +"/.BridgeSortSave");
    if(!fileSave.exists){
    alert("No backup file exists");
    return;
    app.document.sorts = [{ type:"string",name:"document-kind", reverse:false }];
    if(fileSort.exists) fileSort.remove();
    fileSave.copy(fileSort);
    fileSort.hidden=true;
    app.document.chooseMenuItem("mondo/command/new");
    app.documents[0].close();
    app.document.sorts = [{ name:"user",type:"date", reverse:false }];
    Hope this works for you.

  • How do I export my "manual sorting" of files to my new Adobe Bridge CC installation?

    Hi all,
    I'll try to explain my situation:
    I have Adobe Bridge CC installed on my computer. I use the "manual sorting" to view and manage my files (mostly .eps/.psd).
    I'm moving to Win8.1 and I don't want to loose my manual sorting. How do I save/export my manual sorting in order to import it on a new Bridge installation?
    Thank you all in advance,
    Francesco

    I'm moving to Win8.1 and I don't want to loose my manual sorting.
    Manual sorting is not meant for a permanent sort order nor is it designed to do so, when switching to a new window or other sort order you will loose the previous sort order. However there is a way to retrieve the last sort order used with a script Paul Riggott once wrote. But I'm not sure you can transport this sorting to a new system version because when you install a system from scratch you also need to recache the files for the Bridge Cache library. It might be possible to also copy the hidden file with the last sort order but that would mean a trial and error procedure.     
    Check this post, at the bottom is also a link for the site where you can get the script and how to install and use it:
    http://forums.adobe.com/message/4748987#4748987
    Personal I would use batch rename to keep the sort order safe. You can select all files in the content window and add a sequence number in front (with enough digits to match your number of files) of your existing filename. In this way you can easily resort your collection when your manual sorting is lost for whatever reason and also the files will have the correct sort order on your system folder also.

  • Help needed for storing and sorting objects.

    Hello
    I have an assignment and it is to create a guessing game, here is the question,
    In this assignment you are to write a game where a user or the computer is to guess a random
    number between 1 and 1000. The program should for example read a guess from the keyboard, and
    print whether the guess was too high, too low or correct. When the user has guessed the correct
    number, the program is to print the number of guesses made.
    The project must contain a class called Game, which has only one public method. The method must
    be called start(), and, when run it starts the game. The game continues until the user chooses to
    quit, either at the end of a game by answering no to the question or by typing 'quit' instead of a
    guess. After each game has been played, the program is to ask the user for a name and insert this
    together with the number of guesses into a high score list. When a game is started the program
    should print the entire high score list, which must be sorted with the least number of guesses first
    and the most last. Note, the list must be kept as long as the game-object is alive!
    each score also
    consists of the game time. In case there are two high scores with the same number of guesses, the
    game time should decide which is better. The game time starts when the first guess is entered and
    stops when the correct guess has been made. There should also be input checks in the program so
    that it is impossible to input something wrong, i.e. it should be impossible to write an non-numeric
    value then we are guessing a number, the only allowed answers for a yes/no question is yes or no,
    every other input should yield an error message an the question should be printed again.
    I understand how to code most of it, except I am not sure how to store the playerName, playerScore, playerTime and then sort that accordingly.
    I came across hashmaps, but that wont work as the data values can be the same for score.
    Is it only one object of lets say a highScore class, and each time the game finishes, it enters the values into an arrayList, I still dont understand how I can sort the array all at once.
    Should it be sorted once for score, then another array created and sorted again, I dont get it I am confused.
    Please help clarify this.

    Implode wrote:
    We had the arrayList/collections lecture today.
    I asked the teacher about sorting objects and he started explaining hashmaps and then he mentioned another thing which we will only be learning next term, I'm sure we must only use what we have learned.
    How exactly can this be done. I have asked a few questions in the post already.
    ThanksWell, there was probably a gap in the communication. Hash maps (or hash tables, etc.) are instance of Map. Those are used to locate a value by its unique key. Generally, to speed up access, you implement a hashing function (this will be explained hopefully in class). Think of name-value pairs that are stored where the name is unique.
    Contrast this with items that are sorted. Any List can be sorted because its elements are ordered. An ArrayList is ordered, generally, by the order you inserted the elements. However, any List can be given its own ordering via Comparable or Comparator. You can't do this with an ordinary Map. The purpose of a Map is speedy access to the name-value pairs, not sorting. The List likewise has different purposes, advantages, disadvantages, etc. List can be sorted.
    A Map is generally similar to a Set. A Set is a vanilla collection that guarnatees uniqueness of each element (note, not name-value pairs, but simple elements). There is one concrete class of Map that can be sorted, TreeMap, but I doubt your professor was referring to that. The values or the keys can be returned from the Map and sorted separately, but again, I doubt he was referring to that.
    Take a look at the Collections tutorial here on this site or Google one. It is fairly straightforward. Just keep in mind that things (generally) break down into Set, Map and List. There are combinations of these and different flavors (e.g., Queue, LinkedHashMap, etc.) But if you can learn how those three differ, you will go a long way towards understanding collections.
    (Oh, and be sure to study up on iterators.)
    - Saish

  • RE: multiple named objects with the same name andinterface

    David,
    First I will start by saying that this can be done by using named anchored
    objects and registering them yourself in the name service. There is
    documentation on how to do this. And by default you will get most of the
    behavior you desire. When you do a lookup in the name service (BindObject
    method) it will first look in the local partition and see if there is a
    local copy and give you that copy. By anchoring the object and manually
    registering it in the name service you are programmatically creating your
    own SO without defining it as such in the development environment. BTW in
    response to your item number 1. This should be the case there as well. If
    your "mobile" object is in the same partition where the service object he is
    calling resides, you should get a handle to the local instance of the
    service object.
    Here is the catch, if you make a bind object call and there is no local copy
    you will get a handle to a remote copy but you can not be sure which one!
    It end ups as more or less a random selection. Off the top of my head and
    without going to the doc, I am pretty sure that when you register an
    anchored object you can not limit it's visibility to "User".
    Sean
    -----Original Message-----
    From: [email protected]
    [<a href="mailto:[email protected]">mailto:[email protected]]On</a> Behalf Of David Foote
    Sent: Monday, June 22, 1998 4:51 PM
    To: [email protected]
    Subject: multiple named objects with the same name and interface
    All,
    More than once, I have wished that Forte allowed you to place named
    objects with the same name in more than one partition. There are two
    situations in which this seems desirable:
    1) Objects that are not distributed, but are mobile (passed by value to
    remote objects), cannot safely reference a Service Object unless it has
    environment visibility, but this forces the overhead of a remote method
    call when it might not otherwise be necessary. If it were possible to
    place a copy of the same Service Object (with user visibility) in each
    partition, the overhead of a remote method call could be avoided. This
    would only be useful for a service object whose state could be safely
    replicated.
    2) My second scenario also involves mobile objects referencing a Service
    Object, but this time I would like the behavior of the called Service
    Object to differ with the partition from which it is called.
    This could be accomplished by placing Service Objects with the same name
    and the same interface in each partition, but varying the implementation
    with the partition.
    Does anyone have any thoughts about why this would be a good thing or a
    bad thing?
    David N. Foote
    Consultant
    Get Your Private, Free Email at <a href=
    "http://www.hotmail.com">http://www.hotmail.com</a>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>

    David,
    First I will start by saying that this can be done by using named anchored
    objects and registering them yourself in the name service. There is
    documentation on how to do this. And by default you will get most of the
    behavior you desire. When you do a lookup in the name service (BindObject
    method) it will first look in the local partition and see if there is a
    local copy and give you that copy. By anchoring the object and manually
    registering it in the name service you are programmatically creating your
    own SO without defining it as such in the development environment. BTW in
    response to your item number 1. This should be the case there as well. If
    your "mobile" object is in the same partition where the service object he is
    calling resides, you should get a handle to the local instance of the
    service object.
    Here is the catch, if you make a bind object call and there is no local copy
    you will get a handle to a remote copy but you can not be sure which one!
    It end ups as more or less a random selection. Off the top of my head and
    without going to the doc, I am pretty sure that when you register an
    anchored object you can not limit it's visibility to "User".
    Sean
    -----Original Message-----
    From: [email protected]
    [<a href="mailto:[email protected]">mailto:[email protected]]On</a> Behalf Of David Foote
    Sent: Monday, June 22, 1998 4:51 PM
    To: [email protected]
    Subject: multiple named objects with the same name and interface
    All,
    More than once, I have wished that Forte allowed you to place named
    objects with the same name in more than one partition. There are two
    situations in which this seems desirable:
    1) Objects that are not distributed, but are mobile (passed by value to
    remote objects), cannot safely reference a Service Object unless it has
    environment visibility, but this forces the overhead of a remote method
    call when it might not otherwise be necessary. If it were possible to
    place a copy of the same Service Object (with user visibility) in each
    partition, the overhead of a remote method call could be avoided. This
    would only be useful for a service object whose state could be safely
    replicated.
    2) My second scenario also involves mobile objects referencing a Service
    Object, but this time I would like the behavior of the called Service
    Object to differ with the partition from which it is called.
    This could be accomplished by placing Service Objects with the same name
    and the same interface in each partition, but varying the implementation
    with the partition.
    Does anyone have any thoughts about why this would be a good thing or a
    bad thing?
    David N. Foote
    Consultant
    Get Your Private, Free Email at <a href=
    "http://www.hotmail.com">http://www.hotmail.com</a>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>

  • Sorting within iPhoto albums:  eliminate carryover from prior manual sorts?

    I am working with a large series of photos from a recent vacation, arranging the images for captioning and sharing as slideshows.  I've pulled the images over to new albums, one per day, and would ideally sort them once by date, then change to manual sort and adjust a few images' position in the queue.  But when I switch from date sort to manual sort, the images immediately revert to a relatively random-looking order that I think must be the order in which they were edited and then pulled into the finishing album.  Since some of these albums include several hundred photos, the idea of starting over with completely manual sort of all of the images is VERY painful.  Sorting them by date and then copying and dragging the sorted images to a new album, and then resetting to manual sort, reverts them to the same order they had in the previous album.
    Any suggestions for how to fix the date sort some way, then do a fresh manual sort that leaves the date sort as my starting point?
    (and is the question clear?)

    Another thank you. 
    I could not figure out how to manually movie my photos & videos.  "Manually" & "Reset manual" were greyed out in Smart Albums.  So I deleted Smart Albums and just made an "Album."   "Manually & "Reset manual" magically appeared un-greyed.
    Took me awhile to figure out that you can only manually move the last picture or video.

  • Trying to make a book - iPhoto changing the order of my manually sorted album.  Help?

    I'm trying to make a book from an album. 
    I have manually sorted the photos in the album and wanted autoflow to fill the book in.
    However, when I create a new book from the album, iPhoto seems to re-order the photos by one of the other options (eg: by date.)  If I change that sort option under view - sort, and switch it to manual, it wants me to manually re-sort based on the previous setting.  I have already done my sorting in the album.  Is there a configuration I can do that will get iPhoto to recognise that manual album order?
    (iphoto 11 v9.2.1)

    The only solution I've seen reported is to change the dates of the photos using the batch change command with a increment so the date sort will be the same as your manual sort - you can search the forum for one of these posts - and I do not remember how they proposed to undo the date change
    LN

  • Slideshow under Albums start at the end when manually sorted

    Mavericks and iPhoto 9.5.1. Slideshow under Albums start at the end when photos are manually sorted, this was not in the earlier version. When sorted by date the slideshow starts with the first photo.

    This is a know problem with iPhoto  9.5.1.  Report you problem to Apple via http://www.apple.com/feedback/iphoto.html.
    Currently the only workaround is to create the slideshow in the iPhoto slideshow mode and not directly from an album or event.
    OT

  • Help? (Terence or Old Toad) repost: album manual sorting

    Just in the last week, my kids albums won't maintain the manual sorting I have done. It keeps putting several (not all) of the more recent pictures at the very beginning of the album (sorted in order since the day they were born ~1000 pics in each album). I drag them back to the end and everything looks fine, quit and when I reopen iPhoto 11 the photos are back at the beginning. I have deleted and readded the pictures, deleted the preference file in my user library multiple times, rebooted, etc.
    It is only affecting certain pictures, but not even the same ones in my different kid's albums. Frustrating...
    I can't figure this out!
    I would love some help. Thanks!
    P.S.-more info (my computer is the new iMac with the fastest processor).
    I really don't want want to rebuild the library because I have dozens of projects (books, calendars, etc.) that I don't want to lose.
    I originally scanned in many hundreds of photos that were named with dates included. If I batch rename the files with numbers I would lose all of the meticulous naming. Is there a way to just add a number at the beginning of the photo file name. I was thinking maybe if I renamed, then I could just sort by name, but I am not sure how that would carry into the future if I want to do it by date...
    I have everything backed up on Time Machine, but if I revert to a few days ago, do I have to revert everything else too? I spent 4 hours yesterday on iTunes upgrading music to iTunes Plus, updating iPhone software, etc. and I DO NOT want to lose that work either.
    Ideas??

    See my reply to your post in the other topic.

  • Manual sort in Smart Album?

    I want to drag and drop pictures to reorder them in a Smart Album. Seems I've read you can do this but the Manual option is not available (gray) in the drop down. Any advise?

    You're right. Manual sort in a smart album is not an option. Send a feature request to Apple at http://www.apple.com/feedback/iphoto.html.
    You can select the photos in the smart album and create a regular album with them and sort manually there.

  • Manual sorting in album in iPhoto 11 resets itself when I close iPhoto. Any suggestions?

    I'm using iPhoto 11 and am trying to combine photos from three different cameras (so slightly different date/time stamp). I have copied all photos into an album, then sorted by date. Because of variation in date/time I need to sort manually to combine all pics from same activity. So after sorting by date I set view to sort manually. This worked just fine until I closed iPhoto and the manual sorting I had done was lost. Any suggestions?

    from three different cameras (so slightly different date/time stamp)
    Have you tried to adjust the time for the photos from the different cameras?
    You can create three smart albums with the rule "Camera model is" to separate the photos from the three cameras in albums.
    Then select all photos from one of the cameras and use the command "Photos > Adjust Date and Time".  Now you can shift the time of all photos by the same amount, so that the dates in your cameras are perfectly in sync.
    If you get the times in sync you probably need no longer to sort the albums manually, but the sorting should stick, when you close iPhoto.
    Try to repair the iPhoto library with the First Aid Tools.
    Press and hold down the alt/option key ⌥ and the command keys at the same time and launch iPhoto. Keep holding down both keys until you see the First Aid panel.  From the panel select to "Repair database".

Maybe you are looking for